简体   繁体   English

Git合并分支从分离

[英]Git merge branch from detached

I have sample where git merge gives unexpected for me result. 我有git merge给我意外结果的示例

Here master branch has commit #3 with unwanted changes. 在这里, master分支的提交#3进行了不必要的更改。 I checkouts to stable commit #2 and creates new branch with additional usage. 我签出到稳定的提交#2并创建具有其他用法的新分支。 Can I merge new_branch into master with all three lines? 我可以通过所有三new_branch合并到master吗? Thanks for help! 感谢帮助!

提交树

Link to repository 链接到存储库

You can merge new_branch into master then revert #3. 您可以将new_branch合并到master然后还原#3。

Or, you can reset master to new_branch 或者,您可以将master重置为new_branch

git checkout master git reset --hard new_branch

you should make commit #3 and #4 into new_branch, try rebase command 您应该将#3#4提交到new_branch中,尝试使用rebase命令

git checkout new_branch
git rebase master
git checkout master
git merge new_branch

If there is a conflict, you should resolve it. 如果有冲突,您应该解决它。

Or just make your changes into the master branch 或者只是将更改更改到master分支中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM