If the master has changes ahead of the local branch B1 ( branch created off of old master from previous release ) , then how can I merge changes from master ( latest master ) to local branch B1 ( off of previous master ) which also has local changes different from the latest master on same and/or different files.
>> git checkout B1
>> git merge master
Error:
CONFLICT (content): Merge conflict in views/index.html
Auto-merging scripts/services/eService.js
CONFLICT (content): Merge conflict in scripts/services/eScreenService.js
Auto-merging scripts/directives/confirmService.js
Auto-merging scripts/controllers/submitFormController.js
CONFLICT (content): Merge conflict in scripts/controllers/submitFormController.js
Automatic merge failed; fix conflicts and then commit the result.
I need to understand how to handle the code conflict in this situation ? How can i revert back the merge changes in the file ( undo >>>>>>> master
and/or <<<<<<< HEAD
comments from the file git revert HEAD{X}
didn't help )
You can take a step back: git merge --abort
Or you can solve the conflicts manually: git mergetool
(and then commit your changes)
But you may like another option: git rebase
will take your changes away, fast forward the upstream branch to your local branch and then re-apply your changes.
Each way is for another situation, so think a little about what you are trying to achieve.
git-revert
Revert some existing commits, no modifications from the HEAD commit. Git Revert
and you have not committed something yet after conflicts.
git status
is your best friend. it can guide you every second.
git status
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
go for
git merge --abort
this will revert your changes back.
EDIT
You can use
git checkout --ours file
to keep changes of your current branch and remove others. Use --theirs for vice versa.
You can do (when you are in the branch):
git fetch
git rebase origin/master
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.