http://zhidao.baidu.com/link?url=NSYPiSvtGTMoqMA9vt68FRRF8WbfYVmwWeMh47_2lkp0K3jFMl--1Co1tg1R4VshTQV2De1JeG-fh3Ezu5j-3q
What is Git?
Git is currently the world's most advanced distributed version control System (no one).
What are the characteristics of git? Simply put: high-end atmosphere on the grade!
What is the version control system?
If you've written a lengthy speech with Microsoft Word, you must have experienced this:
Want to delete a paragraph, but also afraid of the future to recover to find out what to do? There is a way to first save the current file as ... a new Word file, then change, to a certain extent, and then "Save As ..." a new file, so it has been changed, after a week, you want to retrieve the deleted text, but it is not clear in the deleted before the file, and had to find a file, Really troublesome.
Look at a bunch of messy files, want to keep the latest one, and then delete the other, and afraid of the day will be used, still dare to delete, really depressed.
What's more, some parts need to be filled in by your financial colleague, so you copy the file to her (or you may send a copy to her via email), and then you continue to modify the Word file. After a day, the colleague will pass the word file to you again, at this time, you must think, after sending her to you to receive her document, you made the change, had to put your change and her part merger, really difficult.
So you think, if there is a software, not only can automatically help me to record each file changes, but also allow colleagues to work together to edit, so that you do not have to manage a bunch of similar files, and do not need to pass the file. If you want to see a change, you just have to take a peek at the software, wouldn't it be convenient?
The software should look like this, recording changes to each file:
Version User Description Date
1-Sheet three deleted software terms of service 5 7/12 10:38
2 Zhang three increased the number of license 7/12 18:09
3 John Doe Financial Department adjusted the contract amount 7/13 9:51
4-Sheet Three extended free upgrade cycle 7/14 15:17
In this way, you end up manually managing multiple "versions" of prehistoric times, into version-controlled 20th century.
Build a git server
Building a git server requires a machine running Linux and is highly recommended for Ubuntu or Debian, so you can install it with a few simple apt commands.
Assuming you already have sudo permissions for the user account, below, formally start the installation.
The first step is to install Git:
$ sudo apt-get install git
The second step is to create a git user to run the GIT service:
$ sudo adduser gi
The third step is to create a certificate login:
Collect all the public keys of the users who need to log in, their own id_rsa.pub files, and import all the public keys into the/home/git/.ssh/authorized_keys file, one at a-line.
The fourth step is to initialize the GIT repository:
First select a directory as the Git repository, assuming/srv/sample.git, enter the command in the/SRV directory:
$ sudo git init--bare sample.git
Git creates a bare repository with no workspaces, because the GIT repository on the server is purely for sharing, so you don't let users log on to the server directly to the workspace, and the Git repositories on the server usually end up with. Git. Then, change owner to git:
$ sudo chown-r git:git sample.git
Fifth step, disable the shell login:
For security reasons, the GIT user created in the second step is not allowed to log in to the shell, which can be done by editing the/etc/passwd file. Find a line similar to the following:
git:x:1001:1001:,,,:/home/git:/bin/bas
Switch
git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell
In this way, git users can use git normally via SSH, but cannot log in to the shell because the Git-shell we specify for git users automatically exits every time a login is logged in.
Sixth step, clone the remote repository:
Now, you can clone the remote repository with the git clone command and run it on your own computer:
$ git clone [email protected]:/srv/sample.git
Cloning into ' sample ' ...
Warning:you appear to has cloned an empty repository.
The rest of the push is simple.
Managing Public keys
If the team is small, it is possible to collect everyone's public key and put it in the server's/home/git/.ssh/authorized_keys file. If the team has hundreds of people, it is not possible to play this way, then you can use gitosis to manage the public key.
Here we do not introduce how to play gitosis, hundreds of people's team are basically in the 500 strong, I believe that a high level of Linux administrator problem is not big.
Manage permissions
There are many companies that not only depend on the source code such as life, but also depending on the employees as thieves, will be in the version control system set up a set of comprehensive permissions control, each person has read and write access to each branch or even under each directory. Because Git was developed for Linux source code hosting, Git also inherits the spirit of the open source community and does not support permission control. However, because git supports hooks, it is possible to write a series of scripts on the server side to control the commit and so on, to achieve the purpose of permission control. Gitolite is the tool.
Here we also do not introduce gitolite, do not waste the limited life in the power struggle.
Git is currently the world's most advanced distributed version control System (no one).