Git团队协作工作流程


以github的仓库为例,假定已经配置git并有了自己的github账号。

1,通过github,把团队代码仓库(Fork源)Fork一份到自己的github仓库;

2,从自己的github仓库clone代码到本地(开发用的电脑,Virtual machine..);
git clone git@github.com:Song2017/wordpress-azure.git(ssh key/http url)

3,新建一个分支,便于Fork源代码的管理
git checkout -b dev //新建并转到分支 dev

4,工作的代码应与团队保持一致,git remote update Fork源
git remote add upstream git@github.com:Source/joomla-azure.git //添加Fork源并设置别名upstream
git remote -v  //查看本地仓库对应的远程仓库
//只会将本地库所关联的远程库的commit id更新至最新,代码不会更新,需要继续merge/rebase
git remote update upstream/git fetch upstream
git branch -a
git merge remotes/upstream/master
git pull upstream master //同步Fork源的代码至本地

5,Work with code in local repository.搬砖..

6,提交到自己的github仓库
git status // 查看代码的状态
git add . // 添加所有操作过的代码文件
git commit -m "comment"//统一提交并注释
git push origin dev //向自己的github仓库推送代码 origin:clone的地址git@github.com:Song2017/wordpress-azure.git

7,通过github,向Fork源提出push request.团队管理人进行代码merge。

Tips

a, 推送冲突
$git push origin master
To github.com:Song2017/joomla-azure.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Song2017/joomla-azure.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
1,强制push
git push origin dev -f
2,创建分支
git branch [name]
git push origin [name]
3,查看修改过的code,修改掉冲突的代码

b,git 代码操作指令 远程地址 分支
git pull origin master
pull: 拉取远程仓库代码的指令
origin: 远程仓库的地址,默认为clone的仓库地址git@github.com:Song2017/wordpress-azure.git
master: 远程仓库的分支名称,默认为master

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值