The first step
Install Git: Can be quickly installed by command, different Linux installation methods may not be the same, I am using the Yum method. Ubuntu can use the Apt-get command.
sudo yum install git
Step Two
Add git users, because the GIT server only qualified to do the project code Exchange, specifically to open a user to access the GIT server, better management and control.
sudo adduser git
Step Three
Set the login password for the git user. Because git provides SSH protocol login function, online some of the use of storage client rsa_pub password way to avoid secret login, but I follow this method to store the public key file, modify the configuration of SSH, changed the permissions of the file, the final test can not be, or in Git access prompt for password. So simply set a password for yourself, it is also a bit safer. Workload and the need for users to send public key files to the administrator is the same.
passwd git
Fourth Step
Set the permissions of the git login user. In order to make git remote login, only allow the use of the Git-shell command, you need to modify the/etc/passwd file to find git:x:500:500:,,,:/home/git:/bin/bash This line, generally in the last line, instead of git:x : 500:500:,,,:/home/git:/usr/bin/git-shell note the numbers may be different depending on the actual situation of your computer. After the simple steps above, the GIT environment has been built.
The following is the fourth step in creating a git project: Creating a warehouse. Can be created from an existing project file directory by first entering the project root directory.
Then enter the following command
sudo git init
Fifth Step
Modify the owner of the generated. git file to be a git user
sudo chown-r git:git. git
Sixth step
The above just creates an empty warehouse and needs to add the project file. The following commands are common GIT commands and are used by git. Interested can learn the relevant commands on their own
git Add.
Git commit-a-M "Init a Git Project"
After the above steps, the server-side Git project repository has been established. Other people can clone the project file of the GIT server to local. However, you need to first install the Git-shell tool on your own client. For a friend who already has a GitHub client installed, it's easy to build git directly with its git shell terminal.
git clone <a target=_blank href= "Mailto:[email protected]:/your-git-repository" >[email protected]:/ Your-git-repository</a>
What is the way to build a git server under Linux?