简体   繁体   中英

Git merge branch from detached

I have sample where git merge gives unexpected for me result.

Here master branch has commit #3 with unwanted changes. I checkouts to stable commit #2 and creates new branch with additional usage. Can I merge new_branch into master with all three lines? Thanks for help!

提交树

Link to repository

You can merge new_branch into master then revert #3.

Or, you can reset master to new_branch

git checkout master git reset --hard new_branch

you should make commit #3 and #4 into new_branch, try rebase command

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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