您的位置:首页 > 其它

Git团队协作工作流程

2017-02-07 18:04 369 查看
以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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: