将一个分支的提交合并到另一个分支

merge commits from one branch into another one

使用 bitbucket 和 Atlassian SourceTree 我这样做了:

01/July/2015  - Create the branch 'Branch01' from ' Develop'.

[ ... ]       - Work on 'Branch01'.

01/Agost/2015 - Create the branch 'Brancho02' from 'Develop'.

[ ... ]       - Work on 'Branch01' and 'Branch02'.

01/Oct/2015   - Merge 'Branch02' into 'Develop'.

我想将 Branch02 的提交提交到 Branch01,而不将 'Branch01' 合并到“开发”

我该怎么做?

如果我在合并时发现很多错误,我可以撤消这些更改吗?

可以执行以下命令

git checkout Branch01
git merge Branch02

到此为止:-)

如果您想要从 Branch02 到 Branch01 的任何特定提交

git cherry-pick 'commit-id'

如果您需要所有提交到 Branch01

git checkout Branch01

git merge Branch02

因此将 Branch02 的所有更改带入 Branch01

不幸的是,如果您发现错误或冲突,您只需执行此操作即可重置合并

git reset --hard origin/master

因此您的合并将被还原,Branch01 将恢复到其原始状态

你甚至可以使用

git reset --merge

祝你工作顺利。您可以撤消更改。