#######################################################################################################
qq:1218761836
QQ Group: 150181442
E-mail:[email protected]
#######################################################################################################
Directory
Git Server Build ... 1
1.1 Git protocol Server build ... 1
1.1.1 Install git. 1
1.2.1 Create directory and repository ... 1
1.2.3 Git Server starts ... 2
1.2.4 Client Test ... 4
Building a Git server
A remote repository is usually just a pure warehouse (bare repository)-a repository without a current working directory. Because the warehouse is only a co-operative medium, there is no need to take a snapshot from a state that has been checked out of the hard disk; The repository is just git data. To put it simply, a pure repository is the. Git content of your project.
When you start to set up a git server, you need to export an existing repository to a new, pure repository-a repository that does not contain the current working directory. The method is simple. To clone a warehouse into a pure repository, you can use the--bare option of the Clone command. The directory name for the repository ends with. Git.
Git server build to choose a different protocol according to your needs
GIT support/http/git://ssh://https://file://(local)
Ssh://[[email protected]]host.xz[:p ort]/path/to/repo.git/
git://host.xz[:p ort]/path/to/repo.git/
http[s]://host.xz[:p ort]/path/to/repo.git/
ftp[s]://host.xz[:p ort]/path/to/repo.git/
rsync://host.xz/path/to/repo.git/
1.1 Git protocol Server build 1.1.1 install git
Install git software and use Yum installation method
Yum Install git-*-y install git all packages
Git-all
Git-cvs
Git-daemon
Git-email
Git-gui
Git-svn
Because the server to build the GIT protocol, so Git-daemon is necessary to install, Git-daemon support two startup methods, one is the direct start of Git-daemon, one is to use the xinetd under CentOS to load the git process.
1.2.1 Creating directories and repositories
[Email protected] ~]# mkdir/project/git/-P
[[email protected] git]# git init # Create a git repository
Initialized Empty Git repository in/project/git/.git/
[[email protected] project]# git clone–bare/project/git/.git/my-project.git
Initialized Empty Git repository in/project/my-project.git/
Warning:you appear to has cloned an empty repository.
[Email protected]/]# tree/project/my-project.git/
/project/my-project.git/
├──branches
├──config
├──description
├──head
├──hooks
│├──applypatch-msg.sample
│├──commit-msg.sample
│├──post-commit.sample
│├──post-receive.sample
│├──post-update.sample
│├──pre-applypatch.sample
│├──pre-commit.sample
│├──prepare-commit-msg.sample
│├──pre-rebase.sample
│└──update.sample
├──info
│└──exclude
├──objects
│├──info
│└──pack
└──refs
├──heads
└──tags
9 Directories, files
You can see that these files are actually similar to the SVN configuration file.
1.2.3 Git Server Startup
According to the official website prompted me to use git daemon--reuseaddr--base-path=/project//project/running results failed, in fact, the Git daemon combined with the system operating mode has three kinds, one is the Guardian to run, the latter two are xinetd, Sysinit
I chose the CentOS combination xined, so under CentOS can be combined with xinetd to load git services, in fact, when installing Git-daemon will also install xined this package.
The port of the Git daemon is 9418
[[email protected]/]# grep 9418/etc/services
git 9418/tcp # git pack transfer Service
git 9418/udp # git pack transfer Service
Take a look at the configuration file for the default xined loaded git service, go to man xined to see xined
[Email protected]/]# Cat/etc/xinetd.d/git
# Default:off
# description:the git D?mon allows git repositories to be exported using \
# The GIT://protocol.
Service git
{
Disable = yes
Socket_type = Stream
wait = no
user = Nobody
Server =/usr/libexec/git-core/git-daemon
Server_args =--base-path=/var/lib/git--export-all--user-path=public_git--syslog--inetd--verbose
Log_on_failure + = USERID
}
Completed configuration Files
[Email protected]/]# Vim/etc/xinetd.d/git
# Default:off
# description:the git D?mon allows git repositories to be exported using \
# The GIT://protocol.
Service git
{
Disable = no
Socket_type = Stream
wait = no
user = root
Server =/usr/libexec/git-core/git-daemon
Server_args =--base-path=/project/my-project.git--export-all--user-path=root--syslog--inetd--verbose
Log_on_failure + = USERID
}
~
[Email protected]/]#/etc/init.d/xinetd restart
stopping xinetd: [FAILED]
Starting xinetd: [OK]
[Email protected]/]# Netstat-anlt|grep 9418
TCP 0 0::: 9418:::* LISTEN
1.2.4 Client Testing
You can see that xined in combination with Git is the TCP protocol.
Client-side testing, client-side testing only needs to install Git on the line
[[email protected]/]# git clone git://20.0.0.89/my-project.git sadoc
Initialized Empty Git repository in/sadoc/.git/
Warning:you appear to has cloned an empty repository.
Clone the server's my-project.git to the local sadoc, but in the client test I found that git clone in that directory you cloned the server repository will be your current execution git clone directory
Submit some files on the server and download them on the client side.
[Email protected]/]# CD sadoc/
[[email protected] sadoc]# git remote-v
Origin Git://20.0.0.89/my-project.git (Fetch)
Origin Git://20.0.0.89/my-project.git (push)
[[email protected] sadoc]# git remote
Origin
[Email protected] sadoc]# ls-a
. .. . git
[[email protected] sadoc]# git remote-v
Origin Git://20.0.0.89/my-project.git (Fetch)
Origin Git://20.0.0.89/my-project.git (push)
[[email protected] sadoc]# Touch AA
[[email protected] sadoc]# git add AA
[[email protected] sadoc]# git status
# on Branch Master
#
# Initial Commit
#
# Changes to be committed:
# (use "git rm--cached <file> ..." to Unstage)
#
# New FILE:AA
#
[[email protected] sadoc]# git commit-m "AA" #提交的时候提示我需要配置用户名和邮箱
[Master (root-commit) 90291de] AA
Committer:root <[email protected]>
Your name and email address were configured automatically based
On your username and hostname. Please check the that they is accurate.
You can suppress this message by setting them explicitly:
git config--global user.name "Your name"
git config--global user.email [email protected]
If the identity used for this commit are wrong, you can fix it with:
git commit--amend--author= ' Your Name <[email protected]> '
0 files changed, 0 insertions (+), 0 deletions (-)
Create mode 100644 AA
Reference: Http://www.git-scm.com/book/en/v2
This article is from the "Little Rookie" blog, please be sure to keep this source http://xiaocainiaox.blog.51cto.com/4484443/1702691
Git (learning four) GIT protocol server Setup