git 安装

 

Git 
Mac OS下的安装

export TCL_PATH=`which tclsh`
export NO_MSGFMT=1
export GIT_VERSION='1.6.1'

curl -O "http://kernel.org/pub/software/scm/git/git-1.6.1.tar.gz"
tar zxvf git-1.6.1.tar.gz
cd git-1.6.1
./configure
make
sudo make install

git --version
 

<!-- @page { size: 21.59cm 27.94cm; margin: 2cm } P { margin-bottom: 0.21cm } -->

Git on Ubuntu Server

安装Git-Core:

sudo apt-get update # 可选步骤
sudo apt-get dist-upgrade # 可选步骤

sudo apt-get install git-core


因为要用到 "Gitosis":http://eagain.net/gitweb/?p=gitosis.git;a=blob;f=README.rst ,所有,需要安装python setuptools

sudo apt-get install python-setuptools


安装 Gitosis

mkdir ~/src
cd ~/src
git clone git://eagain.net/gitosis

cd gitosis
sudo python setup.py install


增加名为Git的用户

sudo adduser --system --shell /bin/sh  --gecos 'git version control' --group --disabled-password --home /home/git git


上传公钥到USER用户的根目录下(如果没有,用 ssh-keygen -t rsa 生成)

scp .ssh/id_rsa.pub USER@YOUR_SERVER:
sudo -H -u git gitosis-init < /home/USER/id_rsa.pub
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update


到这一步,基本上都安装好了,到本地进行测试:

git clone git@YOUR_SERVER:gitosis-admin.git

成功后,在本地将有一个gitosis-admin目录,里面有gitosis.conf,keydir。

为Rails项目配置git
打开gitosis.conf,增加一块内容,members为某个用户的公钥~/.ssh/id_rsa.pub中的名字(在该文件的最后在)

[group myrailsapp]
members = vince@urbanpuddle
writable = myrailsapp


然后,提交修改

git commit -a -m "created a new repository"
git push


将本地代码提交到git中

cd myrailsapp
git init


创建 .gitignore 文件,用于忽略某些不需要进行代码管理的内容

.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3


提交代码

git remote add origin git@YOUR_SERVER:myrailsapp.git
git add .
git commit -a -m "initial import"
git push origin master:refs/heads/master


接下来,可以增加成员的公钥到系统中了

cd gitosis-admin
cp ~/alice.pub keydir/
cp ~/bob.pub keydir/
git add keydir/alice.pub keydir/bob.pub


修改gitosis.conf

 [group myteam]
- members = jdoe
+ members = jdoe alice bob
  writable = free_monkey


提交修改

git commit -a -m "Granted Alice and Bob commit rights to FreeMonkey"
git push


其它成员就可以获取代码了

git clone git@YOUR_SERVER:myrailsapp.git


请参考 "Hosting Git repositories, The Easy (and Secure) Way":http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way


 

你可能感兴趣的:(python,ssh,ubuntu,git,Rails)