Version Control-Build a git server and build a git Server
GitHub is a free open-source Git server. If we do not want to disclose the source code of the project and do not want to pay for it, we can build a Git server by ourselves.
Next we will look at how to build a Git server on Ubuntu. We use the vmwarevirtual machine to install two Ubantu systems, respectively named gitServer and gitClient_01.
1. install OpenSSH and configure SSH login without a password
Run sudo apt-get install openssh-server to install the SSH service.
Run ps-e | grep ssh to check whether the ssh service is started.
Run the preceding command to install the SSH service for the Ubantu system and configure SSH password-less login. First, modify the host and ip configuration file gedit/ect/hosts.
2. Create a user git to manage and run the git service.
3. Configure SSH login without a password
On gitClient_01, run the command ssh-keygen-t rsa to generate the key, as shown in figure
After completion. in the ssh directory, we can see the id_rsa and id_rsa.pub files, id_rsa.pub is the public key, and we use the command scp/home/git /. ssh/id_rsa.pub gitServer:/home/git copies the Public Key generated on gitClient_01 to gitServer.
On gitServer, first check whether the authorized_kesys file exists in the/home/git/. ssh directory,
If not, you can use touch authorized_keys to create the file.
After Authorized_keys is created, append the content of the public key id_rsa.pub copied on gitClient_01 to authroized_keys. Note that it is appended to this file, run cat/home/git/id_rsa.pub>/home/git /. ssh/authorized_keys.
After the above content is complete, in gitClient_01, you can use the command ssh gitServer to complete password-free login.
4. Install Git
Run sudo apt-get install git-core to install git
5. Create a git repository storage directory.
6. initialize the server warehouse
Run git-bare init/home/git/myRep. git to initialize the repository.
7. On gitClient_01, run the git clone command to clone the remote repository and run development on the respective computers.
Git clone git @ gitServer:/home/git/myRep. git
Through the above steps, we have completed the establishment of the git server. After the establishment, we need to understand the commands used in the interaction with the git server. The main Commands include git clone, git remote, git fetch, git pull, and git push. Next we will learn one by one
1. git clone
This command is the first step in our interaction with the remote repository. With this command, we can clone the remote repository to a local machine. For example, we used this command in step 1 above, the remote cook road is local.
Syntax: git clone version library URL Local library name
The local library name can be omitted. If the local library name is omitted, a directory with the same name as the remote version library will be generated locally.
2. git remote
This command is used to manage remote host names. This command can list all host names without parameters.
It indicates that the origin is automatically named as the remote host when the clone command is used to clone a remote version library.
Run git remote-v to view the repository URL.
3. git fetch
This command updates the remote version Library to the local database.
Syntax: git fetch Host Name
By default, git fetch origin updates all branches on the remote host origin. If you only want to update a branch, add the branch name after the host name origin.
Syntax: git fetch origin master
4. git push
This command is used to push updates from a local branch to a remote host.
Syntax: git push remote host name local branch name: Remote branch name
If the remote branch name is omitted, the local branch is pushed to the remote branch with the final link. If the remote branch does not exist, it is created.
For example, git pushes the origin master to push the local master branch to the master branch of the origin host.
If the local molecular name is omitted, the branch in the remote host is to be deleted. For example, if git pushes origin: master, the master branch in the origin host is deleted.
5. git pull
This command is used to obtain updates from a remote branch.
Syntax: git pull remote host remote branch: local branch such as git pull origin master: master, indicates that the master branch in the remote host origin is followed by the new master.
To view the full range of Version Control Articles, click: http://www.cnblogs.com/jerehedu/p/4607599.html#bbkz
If you have any questions or technical exchanges, please join the official QQ group: (452379712)
Author: Jerry Education
Source: http://www.cnblogs.com/jerehedu/
The copyright of this article belongs to Yantai Jerry Education Technology Co., Ltd. and the blog Park. You are welcome to repost it. However, you must keep this statement without the author's consent and provide the original article connection on the article page, otherwise, you are entitled to pursue legal liability.