这几天尝试了下用RedHat Linux来配置git server,还是挺顺利的
首先要配置EPEL,要不然就要下载源码编译(比较折腾,就算了),EPEL的配置见
然后开始进行git server的配置
1.安装git-core
yum install git-core
2.初始化一个 repository
[root@bogon first]# git init --bare myprj //这里是工程的放置的目录,myprj为工程名 Initialized empty Git repository in /home/xfx-git/first/myprj/
PS;指定 --bare,当前 repository 下就只有 .git/ 下的 objects,而没有真实文件。一般在 Server 端3.初始化并提交项目
初始化repository后, 我们需要建立个master branch,才能被正常 git clone
[root@bogon first]# cd myprj/ [root@bogon myprj]# mkdir initial.commit [root@bogon initial.commit]# git init Initialized empty Git repository in /home/xfx-git/first/myprj/initial.commit/.git/ [root@bogon initial.commit]# git remote add origin /home/xfx-git/first/myprj/ [root@bogon initial.commit]# touch Readme [root@bogon initial.commit]# git add Readme [root@bogon initial.commit]# git commit -m "inital commit" [master (root-commit) 5b6e14d] inital commit Committer: root <root@bogon.(none)> Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly: git config --global user.name "Your Name" git config --global user.email you@example.com After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Readme [root@bogon initial.commit]# git push origin master Counting objects: 3, done. Unpacking objects: 100% (3/3), done. Writing objects: 100% (3/3), 203 bytes, done. Total 3 (delta 0), reused 0 (delta 0) To /home/xfx-git/first/myprj/ * [new branch] master -> master
4.激活了该 repository, 我们可以正常使用了[root@bogon myclient]$ git clone /home/xfx-git/first/myprj Cloning into 'myprj'... done. [root@bogon myclient]$ cd myprj [root@bogon myprj]$ vim Readme [root@bogon myprj]$ git commit -m "modify readme" Readme [master 1bf69b4] modify readme 1 files changed, 1 insertions(+), 0 deletions(-) [root@bogon myprj]$ git push Counting objects: 5, done. Writing objects: 100% (3/3), 247 bytes, done. Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. To /home/xfx-git/first/myprj 032dad8..1bf69b4 master -> master
5.git的使用,这里转载几种常用的git方法