2009年12月14日星期一

The basic steps for using git in debian/ubuntu


























The basic steps for using git in debian/ubuntu








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 [email protected]:/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 [email protected]:/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)
http://www.urbanpuddle.com/articles/2008/07/11/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



没有评论:

发表评论