Environment: Both CentOS and Ubuntu systems can
CentOS Release 6.7
git version 1.7.1
Git-server 192.168.50.108
Git-client 192.168.50.112
Note: Based on the Linux system to do SSH mode of gitserver, SSH is required to avoid the key, because the git user is forbidden to login, clone without SSH will require a password to prevent operation.
Deployment:
Git-server:
1. Install the GIT software (the same software is used on the client and server side)
Yum Install Git-y
2. Initialize the warehouse (since this is a shared warehouse, all the bare warehouses are to be built)
Mkdir/data/sample.git
Git init--bare/data/sample.git
Chown Git.git/data/sample.git-r
3. Configure the GIT user to use the shell as Git-shell
Which Git-shell (return result/usr/bin/git-shell)
Chsh-s/usr/bin/git-shell git
Git-client:
1. Install the GIT software
Yum Install Git-y
2. Configure the user's SSH key information and provide it to git-server
Ssh-keygen-t rsa-c "[Email protected]" (consistent with git config information, log the file log information to see who modified it.) )
If you are using the root user of this machine, the generated key is default to/root/.ssh/
scp/root/.ssh/id_rsa.pub [Email protected]:/tmp
Git-server:
Allows users of another day of the machine to access git users ' information without a key
Mkdir/home/git/.ssh && Cat Id_rsa.pub >>/home/git/.ssh/authorized_keys
Git-client:
1.clone remote server's bare repository
git clone [email protected]:/data/sample.git
2. Add a remote repository as a source warehouse
git remote add origin [email protected]:/data/sample.git
Git remote-v (view the existing repository source)
2. The default clone is the Master repository, which can be updated directly in the master
CD sample/
echo "This is a test file" >test
3. Configure GIT Global information
git config--global user.name ' test '
git config--global user.email ' [email protected] '
4. Add and submit files
git add test
Git commit-m "This is the fire commit"
5. Share the Git-server source that has been pushed by the modified file
Git push-u Origin Master
Note: Because there are multiple versions of the code and the security Considerations Master is limited, the user can create the branch himself and then request a merge. So most of the changes are not directly on the master. The following are the branch operations
Create a branch after 1.clone maste
Git checkout-b Fenzhi
Git branch (view your current branch)
2. Add and submit files
echo "Hello World" >fenzhifile
git add
Git commit-m ' Fenzhi '
3. Push the new branch to the Git-server source for sharing
Git push Origin Fenzhi
Git-client: Testing
1. Test Master: Change machine (also need to be free of ssh) or change the directory test
Cd/tmp
git clone [email protected]:/data/sample.git
View only one test file, this is what we just added on master.
CD sample/&& Cat Test
2. Test Fenzhi
git clone [email protected]:/data/sample.git-b Fenzhi
The same Fenzhi file also exists, and test also exists. Because we are modified in the main function of master. If the file is not the same, it is a different project.
git help manual
This article is from the "Rookie Growth Diary" blog, please be sure to keep this source http://startlinux.blog.51cto.com/10045010/1754045
"SSH simple version git-server 1" self-built Git-server