cenots 源码安装git 2.7.4

原创 赤水  2016年11月3日 10:38 阅读 3 次
    下面教程基于centos 6.5,git-2.7.4配置安装


yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel 
cd /usr/local/src ; wget https://www.kernel.org/pub/software/scm/git/git-2.7.4.tar.gz --no-check-certificate
tar zxvf git-2.7.4.tar.gz ; cd git-2.7.4
make prefix=/usr/local/git all &&  make prefix=/usr/local/git install
ln -s /usr/local/git/bin/* /usr/bin/
[root@gitserver git-2.7.4]# git --version
git version 2.7.4
[root@gitserver ~]# useradd git
[root@gitserver ~]# su - git 
[git@gitserver ~]$ mkdir bin
[git@gitserver ~]$ git clone https://github.com/sitaramc/gitolite.git 
Cloning into 'gitolite'...
remote: Counting objects: 9307, done.
remote: Total 9307 (delta 0), reused 0 (delta 0), pack-reused 9307
Receiving objects: 100% (9307/9307), 2.93 MiB | 575.00 KiB/s, done.
Resolving deltas: 100% (5756/5756), done.
Checking connectivity... done.

[git@gitserver ~]$ ./gitolite/install --to /home/git/bin/
[git@gitserver ~]$  ls bin/
commands  gitolite  gitolite-shell  lib  syntactic-sugar  triggers  VERSION  VREF
[root@gitserver ~]# ssh-keygen 
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)? 
[root@gitserver ~]# cp ~/.ssh/id_rsa.pub /tmp/admin.pub
[root@gitserver ~]# su git
[git@gitserver root]$ cd 
[git@gitserver ~]$ bin/gitolite setup -pk /tmp/admin.pub 
Initialized empty Git repository in /home/git/repositories/gitolite-admin.git/
Initialized empty Git repository in /home/git/repositories/testing.git/
WARNING: /home/git/.ssh missing; creating a new one
    (this is normal on a brand new install)
WARNING: /home/git/.ssh/authorized_keys missing; creating a new one
    (this is normal on a brand new install)
[git@gitserver ~]$ ls
bin  gitolite  projects.list  repositories
[root@gitserver git-2.7.4]# mkdir /git ; cd /git ; git clone git@
Cloning into 'gitolite-admin'...	'
The authenticity of host ' (' can't be established.
RSA key fingerprint is 1c:32:7d:8f:c9:cc:b2:d8:7e:91:de:be:77:78:95:e3.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
Receiving objects: 100% (6/6), 739 bytes | 0 bytes/s, done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Checking connectivity... done.

test用户在自己服务器上生成ssh无密码公钥ssh-keygen,然后将ssh-keygen复制到git所在服务器,最后test用户的ssh-keygen复制到 gitolite-admin/keydir/下
[root@client ~]# scp ~/.ssh/id_rsa.pub
[root@gitserver git]# cp /tmp/test.pub  /git/gitolite-admin/keydir/
[root@gitserver git]# cat /git/gitolite-admin/conf/gitolite.conf	#默认内容
repo gitolite-admin
    RW+     =   admin

repo testing
    RW+     =   @all
@mygroup    = test
repo mytest    
    RW+     = @mygroup
[root@gitserver git]# cd gitolite-admin/
[root@gitserver gitolite-admin]# git status	#查看git库状态
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
        modified:   conf/gitolite.conf	#修改文件
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        keydir/test.pub					#新增文件
no changes added to commit (use "git add" and/or "git commit -a")

[root@gitserver gitolite-admin]# git commit -m "add repo mytest; add user test"
*** Please tell me who you are.

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'root@gitserver.(none)')'
[root@gitserver gitolite-admin]# git config --global user.email "postmaster@lssin.com"
[root@gitserver gitolite-admin]# git config --global user.name "blog.lssin.com"
[root@gitserver gitolite-admin]# add repo mytest; add user test		#再重新执行git commit命令
 2 files changed, 4 insertions(+)
 create mode 100644 keydir/test.pub
执行完以上命令后,修改的文件只是提交在本地了,并没有提交到git server中,还需要执行git push命令
[root@gitserver gitolite-admin]# git push	 	#推送到远端的master分支
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Counting objects: 6, done.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 821 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
remote: Initialized empty Git repository in /home/git/repositories/mytest.git/
To git@
   6500d14..86e0580  master -> master

[root@gitserver gitolite-admin]# git config --global push.default simple	#忽略plush警告
[root@client ~]# git clone git@
Cloning into 'mytest'...
Address maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
[root@client ~]# git config --global user.email 'test@lssin.com'
[root@client ~]# git config --global user.name 'test'
[root@client ~]# echo `date` > 1.t^C
[root@client ~]# cd mytest/
[root@client mytest]# echo `date` > 1.txt
[root@client mytest]# cat 1.txt 
Wed Nov 2 22:18:50 EDT 2016
[root@client mytest]# git add 1.txt 
[root@client mytest]# git commit -m 'add test file 1.txt'
[master (root-commit) 8bfbc7f] add test file 1.txt
 1 file changed, 1 insertion(+)
 create mode 100644 1.txt
[root@client mytest]# git push origin master	
Address maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
Counting objects: 3, done.
Writing objects: 100% (3/3), 233 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@
 * [new branch]      master -> master



本文地址: https://blog.lssin.com/readblog/122.html
版权声明:本文为原创文章,版权归  赤水 所有,欢迎分享本文,转载请保留出处!