1.创建项目的根仓库remote-repo/proj1
1.1创建仓库并配置
1.初始化仓库
cd remote-repo/proj1
git init
git config --global receive.denyCurrentBranch ignore #让设置可以接受push
- 设push时自动更新:修改根仓库的.git/hooks/post-update.sample文件,在最下边添加以下代码,并注释掉相应代码,将该删除后缀,变为post-update:
#exec git update-server-info 注释掉这一行
unset GIT_DIR
cd ..
git checkout -f
2.公司内部开发
2.1 开发者A创建工作仓库local-repo1
cd local-repo1
git clone xxx/remote-repo/proj1
touch 1.txt #新建文件,作为修改
git add . #将修改添加到暂存区,跟踪文件
git commit -m "local-repo1 commit1" #将暂存区里的改动给提交到本地的版本库
git push -u origin master # origin为远程仓库默认名,就是remote-repo/proj1
2.2 开发者B创建工作仓库local-repo2
cd local-repo2
git clone xxx/remote-repo/proj1
touch 2.txt #新建文件,作为修改
git add . #将修改添加到暂存区,跟踪文件
git commit -m "local-repo2 commit1" #将暂存区里的改动给提交到本地的版本库
git push -u origin master # origin为远程仓库默认名,就是remote-repo/proj1
2.3 …
3. 外出开发
3.1创建外出带走的根仓库out-main-repo/proj1和外出的分支 out
1.初始化仓库
cd out-main-repo/proj1
git init
git config --global receive.denyCurrentBranch ignore #让设置可以接受push
- 设push时自动更新:修改外出带走的根仓库的.git/hooks/post-update.sample文件,在最下边添加以下代码,并注释掉相应代码,将该删除后缀,变为post-update:
#exec git update-server-info 注释掉这一行
unset GIT_DIR
cd ..
git checkout -f
- 创建外出的分支 out,这次外出去现场的代码都提交到out分支上
git checkout -b out
3.2开发者C在外出现场创建工作仓库out-repo1
cd out-repo1
git clone xxx/out-main-repo/proj1
在这个仓库中开发,并提交到out分支上
3.3开发者D在外出现场创建工作仓库out-repo2
cd out-repo2
git clone xxx/out-main-repo/proj1
在这个仓库中开发,并提交到out分支
3.5 …
3.6在公司中的local-repo1、local-repo2…仓库可以继续开发
4 外出带代码回合并
4.1 将外出带走的根仓库out-main-repo/proj1中切换回 master分支 ,并更新mater(更新在公司中修改的代码)
cd out-main-repo/proj1 #进外出带走的根仓
git checkout master #切换回 master分支
git pull #更新 master分支 (更新在公司中修改的代码)
4.2 合并 out分支与master分支
cd out-main-repo/proj1 #进外出带走的根仓库
git checkout master #切换回 master分支
git merge out #将当前分支和out合并
4.3更新项目的根仓库remote-repo/proj1
cd out-main-repo/proj1 #进外出带走的根仓库
git push -u origin master
5 变更git远程仓库地址
https://blog.csdn.net/asdfsfsdgdfgh/article/details/54981823