Chinaunix首页 | 论坛 | 博客
  • 博客访问: 503011
  • 博文数量: 102
  • 博客积分: 4001
  • 博客等级: 上校
  • 技术积分: 756
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-21 16:01
文章分类

全部博文(102)

文章存档

2011年(1)

2010年(1)

2009年(56)

2008年(44)

我的朋友

分类: LINUX

2008-08-22 16:34:26

1. install a git server & initialize a repository

install git-core

$ apt-get install git-core



check the path of git-shell

$ which git-shell
/usr/bin/git-shell



add some users which can access the git server via the git-shell

$ sudo useradd -m -s /usr/bin/git-shell git
$ sudo passwd git
(you can add more users as above)



initialize a git repository: foo

$ sudo mkdir /home/git/foo
$ cd /home/git/foo
$ git --bare init
$ sudo chown -R git:git /home/git/foo



first commit(create the master branch)

$ mkdir foo
$ cd foo
$ git init
$ touch README
$ git add README
$ git commit -m "added README"
$ git remote add origin git@localhost:/home/git/foo
$ git push origin master
$ cd ..; rm -rf foo



2. using git as a client

firstly, you also need to install git-core

$ sudo apt-get git-core



clone the repository from the git server

$ git clone git@your-git-server:/home/git/foo



do a little configuration

$ cd foo
$ git config --global user.name "git"
$ git config --global user.email "git's email"



upgrade(synchronization)

$ git pull



add a new file or directory

$ touch file
$ git add file



add some comments to the above operation

$ git commit -a -m "some comments here..."



submit your operation to the git server

$ git push



that's all, have fun :-)

References & Links

[1] Remote Git Repos on Ubuntu: The Right Way
http://blog.drewolson.org/2008/05/remote-git-repos-on-ubuntu-right-way.html
[2] Installing Git on a server (Ubuntu or Debian)

[3] Hosting Git repositories, The Easy (and Secure) Way
http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
阅读(2499) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~