1. 创建本地库:
假如你的项目在路经/home/ryan/codes/下面:
cd /home/ryan/codes/
git initgit add *
git commit -m "my project"
2. 创建共享库:
假如你的共享库在路径/usr/local/git_repos下面
cd /usr/local/git_repos/
创建一个裸代码库:
mkdir foo.git
cd foo.git/
git --bare init
你可以ll一下看看:
%ll /usr/local/git_repos/foo.git/
total 16
-rw-r--r-- 1 ryan ryan 23 Jun 29 19:04 HEAD
drwxr-xr-x 2 ryan ryan 512 Jun 29 19:04 branches
-rw-r--r-- 1 ryan ryan 66 Jun 29 19:04 config
-rw-r--r-- 1 ryan ryan 73 Jun 29 19:04 description
drwxr-xr-x 2 ryan ryan 512 Jun 29 19:04 hooks
drwxr-xr-x 2 ryan ryan 512 Jun 29 19:04 info
drwxr-xr-x 46 ryan ryan 1024 Jun 29 20:48 objects
drwxr-xr-x 4 ryan ryan 512 Jun 29 19:04 refs
确保权限正确:
git config core.sharedrepository 1
git config receive.denyNonFastforwards true
find objects -type d -exec chmod 02770 {} \;
#The core.sharedrepository 确保所有文件可读可写
#The receive.denyNonFastforwards 确保推送代码到共享库的时候不会合并,你必须在本地做好合并再推送结果
3. 推送代码到共享库
回到你的本地库
cd /home/ryan/codes/
git push -u origin master
iefreer