[root@localhost ~]# yum install git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.yun-idc.com
* updates: mirrors.yun-idc.com
base | 3.7 kB 00:00
extras | 3.3 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 5.3 MB 00:04
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.7.1-3.el6_4.1 will be installed
--> Processing Dependency: perl-Git = 1.7.1-3.el6_4.1 for package: git-1.7.1-3.el6_4.1.x86_64
--> Processing Dependency: perl(Git) for package: git-1.7.1-3.el6_4.1.x86_64
--> Processing Dependency: perl(Error) for package: git-1.7.1-3.el6_4.1.x86_64
--> Running transaction check
---> Package perl-Error.noarch 1:0.17015-4.el6 will be installed
---> Package perl-Git.noarch 0:1.7.1-3.el6_4.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
git x86_64 1.7.1-3.el6_4.1 base 4.6 M
Installing for dependencies:
perl-Error noarch 1:0.17015-4.el6 base 29 k
perl-Git noarch 1.7.1-3.el6_4.1 base 28 k
Transaction Summary
====================================================================================================================================
Install 3 Package(s)
Total download size: 4.7 M
Installed size: 15 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): git-1.7.1-3.el6_4.1.x86_64.rpm | 4.6 MB 00:10
(2/3): perl-Error-0.17015-4.el6.noarch.rpm | 29 kB 00:00
(3/3): perl-Git-1.7.1-3.el6_4.1.noarch.rpm | 28 kB 00:00
------------------------------------------------------------------------------------------------------------------------------------
Total 449 kB/s | 4.7 MB 00:10
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 1:perl-Error-0.17015-4.el6.noarch 1/3
Installing : perl-Git-1.7.1-3.el6_4.1.noarch 2/3
Installing : git-1.7.1-3.el6_4.1.x86_64 3/3
Verifying : git-1.7.1-3.el6_4.1.x86_64 1/3
Verifying : perl-Git-1.7.1-3.el6_4.1.noarch 2/3
Verifying : 1:perl-Error-0.17015-4.el6.noarch 3/3
Installed:
git.x86_64 0:1.7.1-3.el6_4.1
Dependency Installed:
perl-Error.noarch 1:0.17015-4.el6 perl-Git.noarch 0:1.7.1-3.el6_4.1
Complete!
[root@localhost ~]# git --version
git version 1.7.1
[root@localhost ~]# adduser git
[root@localhost data]# mkdir /data/git
[root@localhost data]# cd /data/git/
[root@localhost git]# git init --bare project.git
[root@localhost git]# ls
project.git
[root@localhost git]# cd project.git/
[root@localhost ]# ls
branches config description HEAD hooks info objects refs
[root@localhost project.git]# vim config
[receive]
denyCurrentBranch = ignore
執行以上指令 Git指令,會建立一個裸倉庫,裸倉庫沒有工作區,因為伺服器上的Git倉庫純粹是為了共享,是以不讓使用者直接登入到伺服器上去改工作區,并且伺服器上的Git倉庫通常都以.git結尾。
[root@localhost git]# chown -R git.git project.git
[root@localhost git]# cat /etc/passwd|grep git
git:x:501:501:git version manage:/home/git:/bin/bash
[root@localhost git]# vim /etc/passwd
git:x:501:501:git version manage:/home/git:/usr/bin/git-shell
[root@localhost ~]# ssh-keygen -t rsa
[root@localhost ~]# cd .ssh/
[root@localhost ~]# scp id_rsa.pub 192.168.1.204:/root/
server
cat id_rsa.pub >> /home/git/.ssh/authorized_keys
client git clone [email protected]:/data/git/project.git
git版本沖突
[root@localhost project]$ git stash //緩存起來
Saved working directory and index state WIP on master: 944b9a5 204
HEAD is now at 944b9a5 204
[root@localhost project]$ git pull origin // 分支
Address 192.168.1.204 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
Updating 944b9a5..393a596
Fast-forward
c.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
[root@localhost project]$ git stash pop //還原
Auto-merging c.txt
CONFLICT (content): Merge conflict in c.txt
[root@localhost project]$ git stash clear
[root@localhost project]$ 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 '[email protected]:/data/git/project.git'
解決辦法:git push origin master