We need to install git before we start using Git. Git currently supports running on Linux/unix, Solaris, Mac, and Windows platforms.
The Git platform installation package is: Http://git-scm.com/downloads
First, install Git
Git's work calls for code from libraries such as CURL,ZLIB,OPENSSL,EXPAT,LIBICONV, so you need to install these dependent tools first.
My linux is the CentOS kernel, so you can use the Yum command to install:
$ yum Install curl-devel expat-devel gettext-devel openssl-devel zlib-devel$ yum-y install git-core$ git--versiongit ver Sion 1.71
Second, configure Git
1. Add git user groups and Git users
$ groupadd git$ useradd git-g git-m-s/bin/bash$ passwd git #设置密码 $ vim/etc/sudoers #加上下面一句 git all= (all:all) all, put Git Added to the sudoers user. $ su git #切换到git用户下工作
2. Create a blank warehouse
$ cd ~$ mkdir project.git$ cd project.git$ git init--bare # Create a naked warehouse, why add bare can own Baidu initialized empty git repository in/h ome/git/project.git/
3. Add several user accounts
$ cd ~$ sudo useraddd satan-g git-m-s/bin/bash$ sudo usermod-g git,root Satan #把satan用户同时添加到root和git组 $ sudo passwd sa Tan #设置密码
4. Configure the private key for user Satan
$ mkdir/home/git/.ssh$ Vim/home/git/.ssh/authorized_keys #将用户satan的公钥添加到此文件中, if not created
5. Modify git config
$ vim/home/git/project.git/config #添加如下两行 [receive] Denycurrentbranch = Ignore
6. Restart SSH
$ sudo/etc/init.d/sshd Restart #重启ssh
Third, END
The GIT server configuration is basically complete, leaving only the client to configure the GIT environment, generate the corresponding user's public key, the public key will be added to the Git directory in the Authorized_keys file, can be used.
Linux Build git service (server)