参考 http://wiki.ubuntu.org.cn/Git%E6%9C%8D%E5%8A%A1%E5%99%A8Gitosis%E5%AE%89%E8%A3%85%E8%AE%BE%E7%BD%AE
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android# sudo apt-get install openssh-server openssh-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssh-client is already the newest version.
openssh-client set to manually installed.
openssh-server is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android#sudo apt-get install git-core
Reading package lists... Done
Building dependency tree
Reading state information... Done
git-core is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android#ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? n
为gitosis创建系统用户
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android# sudo useradd -m git
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android#sudo passwd git
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android#sudo mkdir /home/git/repositories
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android#sudo chown git:git /home/git/repositories
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android# sudo chmod 755 /home/git/repositories
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android#git config --global user.name "zhangbin"
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android#git config --global user.email "[email protected]"
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android#sudo apt-get install python-setuptools
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
python-setuptools
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 441 kB of archives.
After this operation, 1,068 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/main python-setuptools all 0.6.24-1ubuntu1 [441 kB]
Fetched 441 kB in 2s (167 kB/s)
Selecting previously unselected package python-setuptools.
(Reading database ... 566042 files and directories currently installed.)
Unpacking python-setuptools (from .../python-setuptools_0.6.24-1ubuntu1_all.deb) ...
Setting up python-setuptools (0.6.24-1ubuntu1) ...
root@Ubuntu32:/home/zhangbin/alex/HiStore/hidolphin060/component/hitranscoder/android#cd /home/git
root@Ubuntu32:/home/git# ls
examples.desktop repositories
root@Ubuntu32:/home/git# mkdir gitosis
root@Ubuntu32:/home/git# cd gitosis/
root@Ubuntu32:/home/git/gitosis# ls
root@Ubuntu32:/home/git/gitosis# git clone https://github.com/res0nat0r/gitosis.git
Cloning into 'gitosis'...
remote: Reusing existing pack: 727, done.
remote: Total 727 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (727/727), 179.60 KiB | 82 KiB/s, done.
Resolving deltas: 100% (407/407), done.
root@Ubuntu32:/home/git/gitosis# ls
gitosis
root@Ubuntu32:/home/git/gitosis# cd gitosis/
root@Ubuntu32:/home/git/gitosis/gitosis# ls
COPYING example.conf lighttpd-gitweb.conf README.rst
debian gitosis MANIFEST.in setup.py
etc-event.d-local-git-daemon gitweb.conf mirror.conf TODO.rst
root@Ubuntu32:/home/git/gitosis/gitosis# cp ~/.ssh/id_rsa.pub .
root@Ubuntu32:/home/git/gitosis/gitosis# ls
COPYING gitosis MANIFEST.in TODO.rst
debian gitweb.conf mirror.conf
etc-event.d-local-git-daemon id_rsa.pub README.rst
example.conf lighttpd-gitweb.conf setup.py
root@Ubuntu32:/home/git/gitosis/gitosis# cd ..
root@Ubuntu32:/home/git/gitosis# cp ~/.ssh/id_rsa.pub .
root@Ubuntu32:/home/git/gitosis# cd ..
root@Ubuntu32:/home/git# ls
examples.desktop gitosis repositories
root@Ubuntu32:/home/git# mv gitosis/ gitosisHome
root@Ubuntu32:/home/git# ls
examples.desktop gitosisHome repositories
root@Ubuntu32:/home/git# cd gitosisHome/
root@Ubuntu32:/home/git/gitosisHome# cd gitosis/
root@Ubuntu32:/home/git/gitosisHome/gitosis# ls
COPYING gitosis MANIFEST.in TODO.rst
debian gitweb.conf mirror.conf
etc-event.d-local-git-daemon id_rsa.pub README.rst
example.conf lighttpd-gitweb.conf setup.py
root@Ubuntu32:/home/git/gitosisHome/gitosis# sudo python setup.py install
running install
Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
/usr/bin/python -E -c pass
TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files
running bdist_egg
running egg_info
creating gitosis.egg-info
writing requirements to gitosis.egg-info/requires.txt
writing gitosis.egg-info/PKG-INFO
writing top-level names to gitosis.egg-info/top_level.txt
writing dependency_links to gitosis.egg-info/dependency_links.txt
writing entry points to gitosis.egg-info/entry_points.txt
writing manifest file 'gitosis.egg-info/SOURCES.txt'
reading manifest file 'gitosis.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'gitosis.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-i686/egg
running install_lib
running build_py
creating build
creating build/lib.linux-i686-2.7
creating build/lib.linux-i686-2.7/gitosis
copying gitosis/serve.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/repository.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/ssh.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/group.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/gitdaemon.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/gitweb.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/run_hook.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/util.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/init.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/app.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/access.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/mirror.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/snagit.py -> build/lib.linux-i686-2.7/gitosis
copying gitosis/__init__.py -> build/lib.linux-i686-2.7/gitosis
creating build/lib.linux-i686-2.7/gitosis/templates
copying gitosis/templates/__init__.py -> build/lib.linux-i686-2.7/gitosis/templates
creating build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/test_access.py -> build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/test_ssh.py -> build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/test_group.py -> build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/test_mirror.py -> build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/test_repository.py -> build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/util.py -> build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/test_run_hook.py -> build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/test_init.py -> build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/test_gitdaemon.py -> build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/test_gitweb.py -> build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/test_serve.py -> build/lib.linux-i686-2.7/gitosis/test
copying gitosis/test/__init__.py -> build/lib.linux-i686-2.7/gitosis/test
creating build/lib.linux-i686-2.7/gitosis/templates/default
creating build/lib.linux-i686-2.7/gitosis/templates/default/hooks
copying gitosis/templates/default/hooks/post-receive -> build/lib.linux-i686-2.7/gitosis/templates/default/hooks
creating build/lib.linux-i686-2.7/gitosis/templates/admin
creating build/lib.linux-i686-2.7/gitosis/templates/admin/hooks
copying gitosis/templates/admin/hooks/post-update -> build/lib.linux-i686-2.7/gitosis/templates/admin/hooks
creating build/bdist.linux-i686
creating build/bdist.linux-i686/egg
creating build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/serve.py -> build/bdist.linux-i686/egg/gitosis
creating build/bdist.linux-i686/egg/gitosis/templates
creating build/bdist.linux-i686/egg/gitosis/templates/default
creating build/bdist.linux-i686/egg/gitosis/templates/default/hooks
copying build/lib.linux-i686-2.7/gitosis/templates/default/hooks/post-receive -> build/bdist.linux-i686/egg/gitosis/templates/default/hooks
creating build/bdist.linux-i686/egg/gitosis/templates/admin
creating build/bdist.linux-i686/egg/gitosis/templates/admin/hooks
copying build/lib.linux-i686-2.7/gitosis/templates/admin/hooks/post-update -> build/bdist.linux-i686/egg/gitosis/templates/admin/hooks
copying build/lib.linux-i686-2.7/gitosis/templates/__init__.py -> build/bdist.linux-i686/egg/gitosis/templates
creating build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/test_access.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/test_ssh.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/test_group.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/test_mirror.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/test_repository.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/util.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/test_run_hook.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/test_init.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/test_gitdaemon.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/test_gitweb.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/test_serve.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/test/__init__.py -> build/bdist.linux-i686/egg/gitosis/test
copying build/lib.linux-i686-2.7/gitosis/repository.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/ssh.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/group.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/gitdaemon.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/gitweb.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/run_hook.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/util.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/init.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/app.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/access.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/mirror.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/snagit.py -> build/bdist.linux-i686/egg/gitosis
copying build/lib.linux-i686-2.7/gitosis/__init__.py -> build/bdist.linux-i686/egg/gitosis
byte-compiling build/bdist.linux-i686/egg/gitosis/serve.py to serve.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/templates/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/test_access.py to test_access.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/test_ssh.py to test_ssh.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/test_group.py to test_group.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/test_mirror.py to test_mirror.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/test_repository.py to test_repository.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/util.py to util.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/test_run_hook.py to test_run_hook.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/test_init.py to test_init.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/test_gitdaemon.py to test_gitdaemon.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/test_gitweb.py to test_gitweb.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/test_serve.py to test_serve.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/test/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/repository.py to repository.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/ssh.py to ssh.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/group.py to group.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/gitdaemon.py to gitdaemon.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/gitweb.py to gitweb.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/run_hook.py to run_hook.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/util.py to util.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/init.py to init.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/app.py to app.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/access.py to access.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/mirror.py to mirror.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/snagit.py to snagit.pyc
byte-compiling build/bdist.linux-i686/egg/gitosis/__init__.py to __init__.pyc
creating build/bdist.linux-i686/egg/EGG-INFO
copying gitosis.egg-info/PKG-INFO -> build/bdist.linux-i686/egg/EGG-INFO
copying gitosis.egg-info/SOURCES.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying gitosis.egg-info/dependency_links.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying gitosis.egg-info/entry_points.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying gitosis.egg-info/not-zip-safe -> build/bdist.linux-i686/egg/EGG-INFO
copying gitosis.egg-info/requires.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying gitosis.egg-info/top_level.txt -> build/bdist.linux-i686/egg/EGG-INFO
creating dist
creating 'dist/gitosis-0.2-py2.7.egg' and adding 'build/bdist.linux-i686/egg' to it
removing 'build/bdist.linux-i686/egg' (and everything under it)
Processing gitosis-0.2-py2.7.egg
creating /usr/local/lib/python2.7/dist-packages/gitosis-0.2-py2.7.egg
Extracting gitosis-0.2-py2.7.egg to /usr/local/lib/python2.7/dist-packages
Adding gitosis 0.2 to easy-install.pth file
Installing gitosis-init script to /usr/local/bin
Installing gitosis-run-hook script to /usr/local/bin
Installing gitosis-serve script to /usr/local/bin
Installed /usr/local/lib/python2.7/dist-packages/gitosis-0.2-py2.7.egg
Processing dependencies for gitosis==0.2
Searching for distribute==0.6.24dev-r0
Best match: distribute 0.6.24dev-r0
Adding distribute 0.6.24dev-r0 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.7 script to /usr/local/bin
Using /usr/lib/python2.7/dist-packages
Finished processing dependencies for gitosis==0.2
root@Ubuntu32:/home/git/gitosisHome/gitosis# ls
build etc-event.d-local-git-daemon gitweb.conf mirror.conf
COPYING example.conf id_rsa.pub README.rst
debian gitosis lighttpd-gitweb.conf setup.py
dist gitosis.egg-info MANIFEST.in TODO.rst
root@Ubuntu32:/home/git/gitosisHome/gitosis# cd git
bash: cd: git: No such file or directory
root@Ubuntu32:/home/git/gitosisHome/gitosis# cd gitosis
root@Ubuntu32:/home/git/gitosisHome/gitosis/gitosis# ls
access.py gitweb.py init.py run_hook.py ssh.py util.py
app.py group.py mirror.py serve.py templates
gitdaemon.py __init__.py repository.py snagit.py test
root@Ubuntu32:/home/git/gitosisHome/gitosis/gitosis# cd ..
root@Ubuntu32:/home/git/gitosisHome/gitosis# ls
build etc-event.d-local-git-daemon gitweb.conf mirror.conf
COPYING example.conf id_rsa.pub README.rst
debian gitosis lighttpd-gitweb.conf setup.py
dist gitosis.egg-info MANIFEST.in TODO.rst
root@Ubuntu32:/home/git/gitosisHome/gitosis# sudo -H -u git gitosis-init < id_rsa.pub
Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/
Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/
root@Ubuntu32:/home/git/gitosisHome/gitosis# sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
root@Ubuntu32:/home/git/gitosisHome/gitosis# cd ~
root@Ubuntu32:~# ls
Desktop ivim tmp_bundle
root@Ubuntu32:~# git clone [email protected]:git/gitosis-admin.git
Cloning into 'gitosis-admin'...
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is 49:f7:21:54:e1:f4:38:16:a7:fa:a8:04:f2:11:ab:3d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts.
ERROR:gitosis.serve.main:Repository read access denied
fatal: The remote end hung up unexpectedly
root@Ubuntu32:~# git clone [email protected]:root/gitosis-admin.git
Cloning into 'gitosis-admin'...
ERROR:gitosis.serve.main:Repository read access denied
fatal: The remote end hung up unexpectedly
root@Ubuntu32:~# git clone [email protected]:gitosis-admin.git 这个就ok了。
Cloning into 'gitosis-admin'...
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 5 (delta 0)
Receiving objects: 100% (5/5), done.
root@Ubuntu32:~# ls
Desktop gitosis-admin ivim tmp_bundle
root@Ubuntu32:~# cd gitosis-admin/
root@Ubuntu32:~/gitosis-admin# ls
gitosis.conf keydir
root@Ubuntu32:~/gitosis-admin#
#######################################################
随后参考如下的过程,在随意一个目录下建立一个空的版本库(类似github的过程)。之后就可以把自己开发的工程导入了。
git iniit
git add
git commit -m
git add remote
git push origin master
root@Ubuntu32:/home/zhangbin/streaming/live/# git remote add origin file:///home/zhangbin/alex/gitProject/meStreamer.git
root@Ubuntu32:/home/zhangbin/streaming/live/streamerBACKUP# git push origin master
Counting objects: 601, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (597/597), done.
Writing objects: 100% (601/601), 39.53 MiB | 4.66 MiB/s, done.
Total 601 (delta 215), reused 0 (delta 0)
To file:///home/zhangbin/alex/gitProject/meStreamer.git
* [new branch] master -> master
root@Ubuntu32:/home/zhangbin/streaming/live/streamer-BACKUP#
##############参考##########################
http://codemelody.wordpress.com/2013/05/28/%E5%BB%BA%E7%AB%8B%E4%B8%80%E4%B8%AAremote-git-repository/
建立一个Remote Git Repository
之前都是在别人已经建立好的Remote上工作,亦或者是只在自己的local repository上工作。假如要发起一个合作,则需要建立一个Remote Git Repository,供别人访问。
假如自己已经有了一个Local Repository,则可以按如下的步骤做这件事
1. 建立一个空的repository
git init --bare shareGit.git
一个shareGit.git的目录将被建立,事实上目录可以任意命名,”.git”是一个约定俗成的名字。
2. 修改此目录的权限,使得后续要用这个repo的人也可以有读写的权限,通常是修改组权限。由于Linux的Permission下层目录不能超出上层目录的权限,所以一开始要选择一个有Group的rwx权限的目录去创建这个shareGit.git目录
3. 为local branch增添这个remote
git remote add origin file:////shareGit.git
如果是远程的话
git remote add origin @://shareGit.git
4. 做一次push
将local的master push到remote上,创建同名分支
4. 至此,别人应该也可以在此目录上工作
git clone file:////shareGit.git
或者
git clone @:/shareGit.git
####################################
https://git.wiki.kernel.org/index.php/RobinSteven/GitChineseTutor/QuickStart
# 建立一个裸版本库( 没有工作目录的 )
foo$ mkdir my-repo.git
foo$ cd my-repo.git
foo$ git --bare init
foo$ chmod a+x .git/hooks/post-update # 用 HTTP 协议来传输版本时要这样
# 并且你需要用 push 命令来植入你的版本库的内容
======================================
http://fsjoy.blog.51cto.com/318484/245106
在git中创建带注释的标签非常简单,在运行'tag'命令时加上-a就可以了。
$ git tag -a v1.4 -m 'version 1.4'
$ git tag
v0.1
v1.3
v1.4
########################################第二个重要过程是搭建gitweb环境#################
zhangbin@Ubuntu32:~$ cd /var/www
zhangbin@Ubuntu32:/var/www$ ls
index.html
gitweb的文件存储在这里:
zhangbin@Ubuntu32:/var/www$ ls /usr/share/gitweb
gitweb.cgi index.cgi static
ubuntu喜欢这里:
zhangbin@Ubuntu32:/var/www$ sudo mkdir /var/www/gitweb
[sudo] password for zhangbin:
zhangbin@Ubuntu32:/var/www$ cd /var/www/gitweb
zhangbin@Ubuntu32:/var/www/gitweb$ sudo ln -s /usr/share/gitweb/* .
这样都指向了gitbweb的文件:
zhangbin@Ubuntu32:/var/www/gitweb$ ls -l
total 0
lrwxrwxrwx 1 root root 28 Jan 21 13:58 gitweb.cgi -> /usr/share/gitweb/gitweb.cgi
lrwxrwxrwx 1 root root 27 Jan 21 13:58 index.cgi -> /usr/share/gitweb/index.cgi
lrwxrwxrwx 1 root root 24 Jan 21 13:58 static -> /usr/share/gitweb/static
gitweb的配置:
zhangbin@Ubuntu32:/var/www/gitweb$ sudo gedit /etc/gitweb.conf
改成 /home/git/repositories
修改apache配置:
zhangbin@Ubuntu32:/var/www/gitweb$ sudo gedit /etc/apache2/conf.d/gitweb
改成/home/git/repositories
zhangbin@Ubuntu32:/var/www/gitweb$ cp /etc/apache2/conf.d/gitweb /etc/apache2/conf.d/gitweb
cp: `/etc/apache2/conf.d/gitweb' and `/etc/apache2/conf.d/gitweb' are the same file
zhangbin@Ubuntu32:/var/www/gitweb$ cp /etc/apache2/conf.d/gitweb /etc/apache2/conf.d/gitweb.BAK
cp: cannot create regular file `/etc/apache2/conf.d/gitweb.BAK': Permission denied
zhangbin@Ubuntu32:/var/www/gitweb$ sudo cp /etc/apache2/conf.d/gitweb /etc/apache2/conf.d/gitweb.BAK
zhangbin@Ubuntu32:/var/www/gitweb$ sudo gedit /etc/apache2/conf.d/gitwebzhangbin@Ubuntu32:/var/www/gitweb$ ls /etc/apache2/conf.d/
charset gitweb~ localized-error-pages security
gitweb gitweb.BAK other-vhosts-access-log
zhangbin@Ubuntu32:/var/www/gitweb$ mv /etc/apache2/conf.d/gitweb.BAK /etc/aacpi/ alternatives/ apg.conf apparmor.d/ at.deny
adduser.conf anacrontab apm/ apport/ at-spi2/
adjtime apache2/ apparmor/ apt/ avahi/
zhangbin@Ubuntu32:/var/www/gitweb$ mv /etc/apache2/conf.d/gitweb.BAK /etc/apache2/conf.d/mygitweb.BAK
mv: cannot move `/etc/apache2/conf.d/gitweb.BAK' to `/etc/apache2/conf.d/mygitweb.BAK': Permission denied
zhangbin@Ubuntu32:/var/www/gitweb$ sudo smv /etc/apache2/conf.d/gitweb.BAK /etc/apache2/conf.d/mygitweb.BAK
sudo: smv: command not found
apache的所有配置文件都会被解析一遍,所以还是删掉这个备份:
zhangbin@Ubuntu32:/var/www/gitweb$ sudo mv /etc/apache2/conf.d/gitweb.BAK /etc/apache2/conf.d/mygitweb.BAK
zhangbin@Ubuntu32:/var/www/gitweb$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2 [Tue Jan 21 14:08:22 2014] [warn] The Alias directive in /etc/apache2/conf.d/mygitweb.BAK at line 1 will probably never match because it overlaps an earlier Alias.
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
... waiting [Tue Jan 21 14:08:23 2014] [warn] The Alias directive in /etc/apache2/conf.d/mygitweb.BAK at line 1 will probably never match because it overlaps an earlier Alias.
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
zhangbin@Ubuntu32:/var/www/gitweb$ rm /etc/apache2/conf.d/mygitweb.BAKrm: remove write-protected regular file `/etc/apache2/conf.d/mygitweb.BAK'? y
rm: cannot remove `/etc/apache2/conf.d/mygitweb.BAK': Permission denied
zhangbin@Ubuntu32:/var/www/gitweb$ sudo rm /etc/apache2/conf.d/mygitweb.BAK
zhangbin@Ubuntu32:/var/www/gitweb$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
有人 http://blog.countableset.ch/2012/04/29/ubuntu-12-dot-04-installing-gitolite-and-gitweb/ 说,安装这个gitolite更好:
zhangbin@Ubuntu32:/var/www/gitweb$ sudo apt-get install gitolite
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
gitolite
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 242 kB of archives.
After this operation, 541 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/universe gitolite all 2.2-1 [242 kB]
Fetched 242 kB in 4s (48.5 kB/s)
Preconfiguring packages ...
Selecting previously unselected package gitolite.
(Reading database ... 566320 files and directories currently installed.)
Unpacking gitolite (from .../gitolite_2.2-1_all.deb) ...
Setting up gitolite (2.2-1) ...
No adminkey given - not setting up gitolite.
zhangbin@Ubuntu32:/var/www/gitweb$ sudo a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart
zhangbin@Ubuntu32:/var/www/gitweb$ service apache2 restart
* Restarting web server apache2 /usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
[fail]
zhangbin@Ubuntu32:/var/www/gitweb$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
这是确保访问不会修改git库的内容:
zhangbin@Ubuntu32:/var/www/gitweb$ cd /home/git/repositories/
zhangbin@Ubuntu32:/home/git/repositories$ sudo chmod -R 755 gitosis-admin.git
zhangbin@Ubuntu32:/home/git/repositories$ ls -al gitosis-admin.git/
total 40
drwxr-xr-x 6 git git 4096 Jan 16 20:46 .
drwxr-xr-x 3 git git 4096 Jan 16 20:46 ..
-rwxr-xr-x 1 git git 66 Jan 16 20:46 config
-rwxr-xr-x 1 git git 95 Jan 16 20:46 gitosis.conf
drwxr-xr-x 3 git git 4096 Jan 16 20:46 gitosis-export
-rwxr-xr-x 1 git git 23 Jan 16 20:46 HEAD
drwxr-xr-x 2 git git 4096 Jan 16 20:46 hooks
-rwxr-xr-x 1 git git 280 Jan 16 20:46 index
drwxr-xr-x 4 git git 4096 Jan 16 20:46 objects
drwxr-xr-x 4 git git 4096 Jan 16 20:46 refs
zhangbin@Ubuntu32:/home/git/repositories$ sudo apt-get install highlight gitweb
Reading package lists... Done
Building dependency tree
Reading state information... Done
gitweb is already the newest version.
The following NEW packages will be installed:
highlight highlight-common
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 520 kB of archives.
After this operation, 1,485 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/universe highlight-common all 3.8-2 [195 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ precise/universe highlight i386 3.8-2 [325 kB]
Fetched 520 kB in 12s (42.6 kB/s)
Selecting previously unselected package highlight-common.
(Reading database ... 566450 files and directories currently installed.)
Unpacking highlight-common (from .../highlight-common_3.8-2_all.deb) ...
Selecting previously unselected package highlight.
Unpacking highlight (from .../highlight_3.8-2_i386.deb) ...
Processing triggers for man-db ...
Setting up highlight-common (3.8-2) ...
Setting up highlight (3.8-2) ...
zhangbin@Ubuntu32:/home/git/repositories$ lst /etc/
The program 'lst' is currently not installed. You can install it by typing:
sudo apt-get install lustre-utils
zhangbin@Ubuntu32:/home/git/repositories$ ls /etc/
acpi gtk-3.0 pnm2ppa.conf
adduser.conf hdparm.conf polkit-1
adjtime highlight popularity-contest.conf
alternatives host.conf ppp
anacrontab hostname printcap
apache2 hostname~ profile
apg.conf hosts profile~
apm hosts~ profile.d
apparmor hosts.allow protocols
apparmor.d hosts.deny pulse
apport hp python
apt idmapd.conf python2.7
at.deny ifplugd rc0.d
at-spi2 iftab rc1.d
avahi ImageMagick rc2.d
bash.bashrc init rc3.d
bash_completion init.d rc4.d
bash_completion.d initramfs-tools rc5.d
bindresvport.blacklist inputrc rc6.d
blkid.conf insserv rc.local
blkid.tab insserv.conf rc.local~
bluetooth insserv.conf.d rcS.d
bonobo-activation iproute2 request-key.conf
brlapi.key issue resolvconf
brltty issue.net resolv.conf
brltty.conf java-6-openjdk rmt
ca-certificates kbd rpc
ca-certificates.conf kernel rsyslog.conf
calendar kernel-img.conf rsyslog.d
chatscripts kerneloops.conf samba
checkbox.d ldap sane.d
checkinstallrc ld.so.cache securetty
chromium-browser ld.so.conf security
clutter-imcontext ld.so.conf.d sensors3.conf
colord.conf legal sensors.d
compizconfig libnl-3 service
ConsoleKit libpaper.d services
console-setup libreoffice sgml
cron.d libuser.conf shadow
cron.daily lightdm shadow-
cron.hourly locale.alias shells
cron.monthly localtime shells.bak
crontab logcheck skel
cron.weekly login.defs smi.conf
cups logrotate.conf snmp
cupshelpers logrotate.d sound
dbus-1 lsb-base speech-dispatcher
debconf.conf lsb-base-logging.sh ssh
debian_version lsb-release ssl
default ltrace.conf subversion
deluser.conf magic sudoers
depmod.d magic.mime sudoers.d
dhcp mailcap su-to-rootrc
dhcp3 mailcap.order sv
dictionaries-common manpath.config sysctl.conf
doc-base menu sysctl.d
dpkg menu-methods systemd
emacs mercurial terminfo
emacs23 mime.types texmf
environment mke2fs.conf thunderbird
event.d modprobe.d timezone
exports modules timidity
exports~ mono tpvmlp.conf
feng.conf motd ts.conf
fenice.conf mountpy.conf ucf.conf
firefox mtab udev
fonts mtab.fuselock ufw
foomatic mtools.conf updatedb.conf
fstab nanorc update-manager
fstab~ netconfig update-motd.d
fstab.bak netscsid.conf update-notifier
fstab.d network UPower
fuse.conf NetworkManager usb_modeswitch.conf
gadmin-samba networks usb_modeswitch.d
gai.conf newt vdpau_wrapper.cfg
gconf nsswitch.conf vim
gdb obex-data-server vmware-tools
ghostscript ODBCDataSources vtrgb
ginn odbc.ini wgetrc
gitweb.conf odbcinst.ini wildmidi
gitweb.conf~ openal wireshark
gnome opt wodim.conf
gnome-app-install os-release wpa_supplicant
gnome-settings-daemon pam.conf X11
gnome-vfs-2.0 pam.d xdg
groff papersize xinetd.conf
group passwd xinetd.conf~
group- passwd- xinetd.d
grub.d pcmcia xml
gshadow perl xul-ext
gshadow- php5 zsh_command_not_found
gssapi_mech.conf pkcs11
gtk-2.0 pm
zhangbin@Ubuntu32:/home/git/repositories$ cat /etc/gitweb.conf
# path to git projects (.git)
$projectroot = "/home/git/repositories";
# directory to use for temp files
$git_temp = "/tmp";
# target of the home link on top of all pages
#$home_link = $my_uri || "/";
# html text to include at home page
#$home_text = "indextext.html";
# file with project list; by default, simply scan the projectroot dir.
#$projects_list = $projectroot;
# stylesheet to use
#@stylesheets = ("static/gitweb.css");
# javascript code for gitweb
#$javascript = "static/gitweb.js";
# logo to use
#$logo = "static/git-logo.png";
# the 'favicon'
#$favicon = "static/git-favicon.png";
# git-diff-tree(1) options to use for generated patches
#@diff_opts = ("-M");
@diff_opts = ();
zhangbin@Ubuntu32:/home/git/repositories$
####
访问 http://localhost/cgi-bin/gitweb.cgi
参考 http://www.lucidlynx.com/how-to-install-gitweb-in-ubuntu/
参考 http://blog.countableset.ch/2012/04/29/ubuntu-12-dot-04-installing-gitolite-and-gitweb/
###################将gitweb访问的repo路径指向我本地的真实repo路径############
我没有在在/home/git下建设repo,而是放在了我的其他硬盘sdb上的文件夹中。
gitweb會scan你放在/git下所有的repository,並且顯示在網頁上。所以要修改/etc/gitweb.conf,修改repo路径为/home/zhangbin/alex/gitProject
重启apache:
zhangbin@Ubuntu32:/home/git/repositories$ sudo gedit /etc/gitweb.conf
zhangbin@Ubuntu32:/home/git/repositories$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
zhangbin@Ubuntu32:/home/git/repositories$
重新访问访问 http://localhost/cgi-bin/gitweb.cgi 就有当前目录下的git们了。
=======================
++++++++++++ 参考 http://blog.xuite.net/yctseng/notes/35220134-gitweb
今天在搞gitweb,想要能過透過browser來瀏覽git repository,搞了一天,記錄一下心得。
原來gitweb跟透過http做git operations其實算是兩回事,不是像我呆呆的把web跟http想成是同義詞ㄋㄟ~ XD
gitweb:
像這種東西啦~ http://git.kernel.org/,其實他是透過一個gitweb.cgi來瀏覽git repository的內容,但並沒有提供讓你clone、push的機制,不過他有提供暴力的snapshot,把選定版本的project整個打包下載。
透過http做git operations:
config你的apache server讓使用者可以透過http protocol存取到git repository,可以進行所有git的operation(應該就跟ssh一樣,只是protocol不一樣)。
============================================================
gitweb設定 (on Ubuntu 10.04)
1. # apt-get install apache2
www root預設在 /var/www
2. # apt-get install gitweb
3. # cp /usr/share/gitweb/git* /var/www
4. # vi /etc/gitweb.conf
$projectroot = "/git"; # git repository在filesystem裡的path
$git_temp = "/tmp";
$home_text = "/var/www/index.html" #可以在git project list那頁的開頭放一些文字說明
$projects_list = $projectroot;
$stylesheet = "/gitweb.css"; # 步驟3 copy到/var/www的東西
$logo = "/git-logo.png"; # 步驟3 copy到/var/www的東西
$favicon = "/git-favicon.png"; # 步驟3 copy到/var/www的東西
5. # vi /etc/apache2/conf.d/gitweb # 如果這檔案已經存在,千萬千萬要確認內容要跟底下一樣
Alias /git /git #前面的/git代表的是browser連線時url中,ServerName後面的名字,後面的/git代表git repository,兩者不一定要一樣。
Options Indexes FollowSymlinks ExecCGI
DirectoryIndex /cgi-bin/gitweb.cgi #指到/usr/lib/cgi-bin/gitweb.cgi
AllowOverride None
6. # vi /usr/lib/cgi-bin/gitweb.cgi
#our $home_link_str = "projects";
our $home_link_str = "git"; #出現在gitweb網頁上path的開頭,我喜歡改成git讓path跟網頁裡的一致。
7. # /etc/init.d/apache2 restart
8. use browser to view http://10.18.130.124/git
============================================================
基本上,gitweb會scan你放在/git下所有的repository,並且顯示在網頁上。最後還有幾件事情也要記得:
1. owner
gitweb上的owner不是直接顯示username,而是抓取Full Name的那個欄位,在/etc/passwd中的話,就是group id後面一個欄位,如果你那一欄沒填的話,owner會空白喔~
2. --bare
create repository的時候,用--bare的方式產生出來會比較好看 (--bare的實際意義先不管 :p)
--bare: mygitserver.git
no --bare: mygitserver/.git
3. git operations via http
這裡完全不談論git operations via http的設定,git operations的路徑可以設定的跟gitweb一樣,都是http://gitserver/git/xxx.git,讓兩邊的url一致不會造成困擾。但是因為git operations via http的效率"聽說"比較慢,所以我比較傾向於用ssh就好。既然這樣,git operations via http就先不管了,等真的有需要再來研究怎麼設定。
註:裝apache2.2-common時一直遇到問題,用下面的command把 pkg整個移除掉
dpkg --purge --force-remove-reinstreq apache2.2-common
在其他package遇到問題時,同樣可以用這個command清一下。
==================================
/etc/gitweb.conf 中還有一些設定可以調整
$site_name = "Page title"; #顯示網頁title的名稱
$feature{'search'}{'default'} = [undef];
$feature{'blame'}{'default'} = [undef];
$feature{'snapshot'}{'default'} = [undef];
上面這三個feature,要關掉的話就用[undef]。
要打開的話,search跟blame就把後面的[undef]改成[1],而snapshot的話,可以改成['tgz', 'tbz2', 'zip'],這樣的話代表提供了這三種format的壓縮格式可供下載code。
關鍵字:gitweb Ubuntu apache2
Reference:
http://blogs.koolwal.net/2009/08/08/gitweb-host-repositories-apache-server/
+++++++++++++++