Git centos6.3

 

git git gitweb
 
GIT 安装
1,安装
 [root@cn-dns-test03 /]# yum install git
 [root@cn-dns-test03 home]# useradd --home /home/git git
[root@cn-dns-test03 home]# passwd git
Changing password for user git.
New password:
BAD PASSWORD: it does not contain enough DIFFERENT characters
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
 
 
2,配置目录
[root@cn-dns-test03 home]# su - git
[git@cn-dns-test03 ~]$ pwd
/home/git
[git@cn-dns-test03 ~]$ ls
[git@cn-dns-test03 ~]$ mkdir repo
[git@cn-dns-test03 ~]$ ls
repo
[git@cn-dns-test03 ~]$ chmod -R 755 /home/git
[git@cn-dns-test03 ~]$ git config --global user.name "root"
[git@cn-dns-test03 ~]$ git config --global user.email "[email protected]"
 
 
[git@cn-dns-test03 ~]$ ls -al
total 32
drwxr-xr-x 4 git git 4096 Jan 5 15:14 .
drwxr-xr-x. 3 root root 4096 Jan 5 15:10 ..
-rwxr-xr-x 1 git git     18 May 11 2012 .bash_logout
-rwxr-xr-x 1 git git    176 May 11 2012 .bash_profile
-rwxr-xr-x 1 git git    124 May 11 2012 .bashrc
-rw-rw-r-- 1 git git     48 Jan 5 15:14 .gitconfig
drwxr-xr-x 2 git git 4096 Nov 12 2010 .gnome2
drwxr-xr-x 2 git git 4096 Jan 5 15:12 repo
 
 
[git@cn-dns-test03 ~]$ cat .gitconfig
[user]
        name = root
        email = [email protected]
[git@cn-dns-test03 ~]$
 
 
[git@cn-dns-test03 ~]$ mkdir columbus
[git@cn-dns-test03 ~]$ cd columbus/
[git@cn-dns-test03 columbus]$ git init --bare
Initialized empty Git repository in /home/git/columbus/
 
切换用户
[git@cn-dns-test03 repo]$ su - root
[root@cn-dns-test03 ~]# mkdir ocolumbus
[root@cn-dns-test03 ocolumbus]# cd columbus
[root@cn-dns-test03 ocolumbus]# git clone /home/git/columbus/
Initialized empty Git repository in /root/ocolumbus/columbus/.git/
warning: You appear to have cloned an empty repository.
 
 
[root@cn-dns-test03 columbus]# vi a.txt
[root@cn-dns-test03 columbus]# git status
# On branch master
#
# Initial commit
#
# Untracked files:
#    (use "git add <file>..." to include in what will be committed)
#
#        a.txt
nothing added to commit but untracked files present (use "git add" to track)
[root@cn-dns-test03 columbus]# git add .
[root@cn-dns-test03 columbus]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#  (use "git rm --cached <file>..." to unstage)
#
#        new file:   a.txt
#
[root@cn-dns-test03 columbus]# git commit -a
Aborting commit due to empty commit message.
[root@cn-dns-test03 columbus]# git commit -m a.txt
[master (root-commit) 1809015] a.txt
 Committer: root <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
 
    git config --global user.name "Your Name"
    git config --global user.email [email protected]
 
If the identity used for this commit is wrong, you can fix it with:
 
    git commit --amend --author='Your Name <[email protected]>'
 
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a.txt
[root@cn-dns-test03 columbus]# git push
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '/home/git/columbus/'
[root@cn-dns-test03 columbus]# git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 218 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in som
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /home/git/columbus/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/home/git/columbus/'
[root@cn-dns-test03 columbus]#
以上git安装设置完毕。
 
 
二 gitis
 
[root@cn-dns-test03 ~]# yum install python-setuptools

[root@cn-dns-test03 ~]# git clone https://github.com/res0nat0r/gitosis.git
Initialized empty Git repository in /root/gitosis/.git/
remote: Counting objects: 727, done.
remote: Compressing objects: 100% (217/217), done.
remote: Total 727 (delta 510), reused 690 (delta 494)
Receiving objects: 100% (727/727), 110.70 KiB | 111 KiB/s, done.
Resolving deltas: 100% (510/510), done.
 
[root@cn-dns-test03 ~]# ls
anaconda-ks.cfg gitosis install.log install.log.syslog ocolumbus
[root@cn-dns-test03 ~]# cd gitosis/
[root@cn-dns-test03 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@cn-dns-test03 gitosis]# python setup.py install
 
 
[root@cn-dns-test03 gitosis]# su - git
[git@cn-dns-test03 ~]$ ls
columbus repo
[git@cn-dns-test03 ~]$ pwd
/home/git
[git@cn-dns-test03 ~]$ ssh
ssh           ssh-agent    sshd         ssh-keyscan
ssh-add       ssh-copy-id ssh-keygen
[git@cn-dns-test03 ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/git/.ssh/id_rsa):
Created directory '/home/git/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/git/.ssh/id_rsa.
Your public key has been saved in /home/git/.ssh/id_rsa.pub.
The key fingerprint is:
0b:9e:9b:c0:ec:92:8c:83:55:b0:3a:f8:a6:0d:f3:8f [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|                  |
| .               |
|    o             |
| . .             |
|.. . . S         |
|+ .o . o .        |
|+* .+ o .         |
|+=*o . o          |
|.+Eoo o           |
+-----------------+
[git@cn-dns-test03 ~]$
[git@cn-dns-test03 ~]$ gitosis-init < /home/git/.ssh/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/
[git@cn-dns-test03 ~]$
[git@cn-dns-test03 ~]$ chmod u+x /home/git/repositories/gitosis-admin.git/hooks/post-update
以上服务器端设置完成
[root@cn-dns-test03 ocolumbus]# git clone [email protected]:/home/git/repositories/gitosis-admin.git/
Initialized empty Git repository in /root/ocolumbus/gitosis-admin/.git/
The authenticity of host '192.168.0.243 (192.168.0.243)' can't be established.
RSA key fingerprint is 76:29:16:5d:b5:fe:3b:8c:35:a2:ae:01:7e:1e:5a:a3.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.243' (RSA) to the list of known hosts.
[email protected]'s password:
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
Receiving objects: 100% (5/5), 774 bytes, done.
remote: Total 5 (delta 0), reused 5 (delta 0)
[root@cn-dns-test03 ocolumbus]# ls
columbus gitosis-admin
[root@cn-dns-test03 ocolumbus]#
查看
[root@cn-dns-test03 gitosis-admin]# cat gitosis.conf
[gitosis]
 
[group gitosis-admin]
writable = gitosis-admin
members = [email protected]
 
[root@cn-dns-test03 gitosis-admin]#
 
修改
[root@cn-dns-test03 gitosis-admin]# vi gitosis.conf
[root@cn-dns-test03 gitosis-admin]# cat gitosis.conf
[gitosis]
 
[group gitosis-admin]
writable = gitosis-admin
members = [email protected]
 
[group tocolumbus]
writeable = tocolumbus
members = [email protected]
[root@cn-dns-test03 gitosis-admin]#
 
[root@cn-dns-test03 gitosis-admin]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
b5:a1:4f:fb:a5:9a:6d:f0:b6:db:4b:01:cd:ba:0f:57 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|                  |
|              o   |
|           o . o |
|          o o o   |
|         S o . . E|
|          o.. . o |
|           ooo + |
|            ++O   |
|           o+*o+. |
+-----------------+
[root@cn-dns-test03 gitosis-admin]#
[root@cn-dns-test03 keydir]# cp /root/.ssh/id_rsa.pub /root/ocolumbus/gitosis-admin/keydir/
 
[root@cn-dns-test03 gitosis-admin]# git add ./
[root@cn-dns-test03 gitosis-admin]# git commit -a
Aborting commit due to empty commit message.
[root@cn-dns-test03 gitosis-admin]# git commit -m 'test'
[master 9631cb8] test
 2 files changed, 4 insertions(+), 0 deletions(-)
 create mode 100644 keydir/id_rsa.pub
[root@cn-dns-test03 gitosis-admin]# git push
[email protected]'s password:
Counting objects: 8, done.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 823 bytes, done.
Total 5 (delta 0), reused 0 (delta 0)
To [email protected]:/home/git/repositories/gitosis-admin.git/
   ae4fd3b..9631cb8 master -> master
[root@cn-dns-test03 gitosis-admin]#
 
 
 
建立第二个仓库
git@cn-dns-test03 repositories]$ cd gitosis-admin.git/
[git@cn-dns-test03 gitosis-admin.git]$ ls
config gitosis.conf gitosis-export HEAD hooks index info objects refs
[git@cn-dns-test03 gitosis-admin.git]$ cat gitosis
cat: gitosis: No such file or directory
[git@cn-dns-test03 gitosis-admin.git]$ cat gitosis.conf
[gitosis]
 
[group gitosis-admin]
writable = gitosis-admin
members = [email protected]
 
[group tocolumbus]
writeable = tocolumbus
members = [email protected]
[git@cn-dns-test03 gitosis-admin.git]$
 
[git@cn-dns-test03 gitosis-admin.git]$ mkdir tocolumbus.git
[git@cn-dns-test03 gitosis-admin.git]$ ls
config         gitosis-export hooks info     refs
gitosis.conf HEAD             index objects tocolumbus.git
[git@cn-dns-test03 gitosis-admin.git]$ cd tocolumbus.git/
[git@cn-dns-test03 tocolumbus.git]$ ls
[git@cn-dns-test03 tocolumbus.git]$ git init --bare
Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/tocolumbus.git/
[git@cn-dns-test03 tocolumbus.git]$ ls
branches config description HEAD hooks info objects refs
[git@cn-dns-test03 tocolumbus.git]$
 
 
 
 
[root@cn-dns-test03 gitosis-admin.git]# pwd
/home/git/repositories/gitosis-admin.git
[root@cn-dns-test03 gitosis-admin.git]# ls
config         gitosis-export hooks info     refs
gitosis.conf HEAD             index objects tocolumbus.git
[root@cn-dns-test03 gitosis-admin.git]# git clone [email protected]:/home/git/repositories/gitosis-admin.git/tocolumbus.git/
Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/tocolumbus/.git/
[email protected]'s password:
warning: You appear to have cloned an empty repository.
[root@cn-dns-test03 gitosis-admin.git]#
 
 
 
[root@cn-dns-test03 gitosis-admin.git]# cd tocolumbus
[root@cn-dns-test03 tocolumbus]# ls
[root@cn-dns-test03 tocolumbus]# ls -al
total 12
drwxr-xr-x 3 root root 4096 Jan 5 16:46 .
drwxr-x--- 9 git git 4096 Jan 5 16:46 ..
drwxr-xr-x 7 root root 4096 Jan 5 16:46 .git
[root@cn-dns-test03 tocolumbus]# vim ab.txt
[root@cn-dns-test03 tocolumbus]# git status
# On branch master
#
# Initial commit
#
# Untracked files:
#    (use "git add <file>..." to include in what will be committed)
#
#        ab.txt
nothing added to commit but untracked files present (use "git add" to track)
[root@cn-dns-test03 tocolumbus]# git add ./
[root@cn-dns-test03 tocolumbus]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#    (use "git rm --cached <file>..." to unstage)
#
#        new file:   ab.txt
#
[root@cn-dns-test03 tocolumbus]# git commit -m "send re"
[master (root-commit) 485913b] send re
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 ab.txt
[root@cn-dns-test03 tocolumbus]#
以上gitis配置完成
 
三 gitweb
 
 
[root@cn-dns-test03 usr]# yum install httpd
[root@cn-dns-test03 usr]# yum install gitweb-1.7.1-2.el6_0.1.noarch.rpm
 
[root@cn-dns-test03 usr]# cd /var/www/
[root@cn-dns-test03 www]# ls
cgi-bin error git html icons
[root@cn-dns-test03 www]# cd git/
[root@cn-dns-test03 git]# ls
git-favicon.png git-logo.png gitweb.cgi gitweb.css gitweb.js
[root@cn-dns-test03 git]#
[root@cn-dns-test03 git]# vi /etc/gitweb.conf
[root@cn-dns-test03 git]# cat /etc/gitweb.conf
# The gitweb config file is a fragment of perl code. You can set variables
# using "our $variable = value"; text from "#" character until the end of a
# line is ignored. See perlsyn(1) man page for details.
#
# See /usr/share/doc/gitweb-*/README and /usr/share/doc/gitweb-*/INSTALL for
# more details and available configuration variables.
 
# Set the path to git projects. This is an absolute filesystem path which will
# be prepended to the project path.
#our $projectroot = "/var/lib/git";
$projectroot = "/var/www/git";
# Set the list of git base URLs used for URL to where fetch project from, i.e.
# the full URL is "$git_base_url/$project". By default this is empty
#our @git_base_url_list = qw(git://git.example.com
#                             ssh://git.example.com/var/lib/git);
 
# Enable the 'blame' blob view, showing the last commit that modified
# each line in the file. This can be very CPU-intensive. Disabled by default
#$feature{'blame'}{'default'} = [1];
#
# Allow projects to override the default setting via git config file.
# Example: gitweb.blame = 0|1;
#$feature{'blame'}{'override'} = 1;
 
# Disable the 'snapshot' link, providing a compressed archive of any tree. This
# can potentially generate high traffic if you have large project. Enabled for
# .tar.gz snapshots by default.
#
# Value is a list of formats defined in %known_snapshot_formats that you wish
# to offer.
#$feature{'snapshot'}{'default'} = [];
#
# Allow projects to override the default setting via git config file.
# Example: gitweb.snapshot = tbz2,zip; (use "none" to disable)
#$feature{'snapshot'}{'override'} = 1;
 
# Disable grep search, which will list the files in currently selected tree
# containing the given string. This can be potentially CPU-intensive, of
# course. Enabled by default.
#$feature{'grep'}{'default'} = [0];
#
# Allow projects to override the default setting via git config file.
# Example: gitweb.grep = 0|1;
#$feature{'grep'}{'override'} = 1;
 
# Disable the pickaxe search, which will list the commits that modified a given
# string in a file. This can be practical and quite faster alternative to
# 'blame', but still potentially CPU-intensive. Enabled by default.
#$feature{'pickaxe'}{'default'} = [0];
#
# Allow projects to override the default setting via git config file.
# Example: gitweb.pickaxe = 0|1;
#$feature{'pickaxe'}{'override'} = 1;
[root@cn-dns-test03 git]#
 
[root@cn-dns-test03 git]# vi /etc/httpd/conf.d/git.conf
 
[root@cn-dns-test03 git]# cat /etc/httpd/conf.d/git.conf
Alias /git /var/www/git
 
<Directory /var/www/git>
 Allow from all
 AllowOverride all
 Order allow,deny
 Options +ExecCGI
 AddHandler cgi-script .cgi
 DirectoryIndex gitweb.cgi
 SetEnv GITWEB_CONFIG /etc/gitweb.conf
</Directory>
[root@cn-dns-test03 git]#
 
 
 
[root@cn-dns-test03 git]# cp -R columbus/ /var/www/git/
http://192.168.0.243/git/gitweb.cgi
 
 
 
 
 
 
 
 

你可能感兴趣的:(git,centos6.3)