git 外带开发场景设想

1.创建项目的根仓库remote-repo/proj1

1.1创建仓库并配置

1.初始化仓库

cd remote-repo/proj1
git init 
git config --global receive.denyCurrentBranch ignore #让设置可以接受push 
  1. 设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 
  1. 设push时自动更新:修改外出带走的根仓库的.git/hooks/post-update.sample文件,在最下边添加以下代码,并注释掉相应代码,将该删除后缀,变为post-update:
#exec git update-server-info 注释掉这一行
unset GIT_DIR
cd ..
git checkout -f
  1. 创建外出的分支 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值