1

开发人员 A 正在开发分支 2012A

我分支 2012A,并创建分支 2012B

我想要 2012A 的所有新变化,所以我只想将它们合并到 2012B 中并继续工作。

这看起来可以作为工作流程吗?

git checkout 2012A (switch to 2012A)
git pull origin 2012A (update 2012A)
git checkout 2012B (switch to 2012B)

git merge 2012A (merge in 2012A)
git commit -m 'commiting changes from 2012A' (commit changes from 2012A in 2012B)

提前致谢,

4

1 回答 1

3

It should work, however you could do it in a simpler way:

directly from branch 2012B:

git fetch origin
git merge origin/2012A

Note that you are not required to have a local branch for 2012A: if have a repository in your remotes (here your remote is origin) you usually carry the snapshots of the remote branches. You can see them by running:

git branch -a

(See the remotes/... entries of the output)

The git fetch command updates the snapshots, so git fetch origin updates your local images of the remote branches in origin, and git merge origin/2012A merges such image into the current branch (i.e. applies the patches of origin/2012A on 2012B).


Suggested article: http://longair.net/blog/2009/04/16/git-fetch-and-merge/

于 2012-11-30T11:53:11.877 回答