I don't want a visual merge tool, and I also don't want to have to vi the conflicted file and manually choose the between HEAD (mine) and the imported change (theirs). Most of the time I either want all of their changes or all of mine. Commonly this is because my change made it upsteam and is coming back to me through a pull, but may be slightly modified in various places.
Is there a command line tool which will get rid of the conflict markers and choose all one way or another based on my choice? Or a set of git commands which I can alias myself to do each one.
# accept mine
alias am="some_sequence;of;commands"
alias at="some_other_sequence;of;commands"
Doing this is rather annoying.
For 'accept mine' I have tried:
randy@sabotage ~/linus $ git merge test-branch
Auto-merging Makefile
CONFLICT (content): Merge conflict in Makefile
Automatic merge failed; fix conflicts and then commit the result.
randy@sabotage ~/linus $ git checkout Makefile
error: path 'Makefile' is unmerged
andy@sabotage ~/linus $ git reset --hard HEAD Makefile
fatal: Cannot do hard reset with paths.
How am I supposed to get rid of these change markers?
I can do:
git reset HEAD Makefile; rm Makefile; git checkout Makefile
But this seems rather round about, there must be a better way. And at this point, I'm not sure if git even thinks the merge happened, so I don't think this necessarily even works.
Going the other way, doing 'accept theirs' is equally messy.
The only way I can figure it out is do:
git show test-branch:Makefile > Makefile; git add Makefile;
This also gives me a messed up commit message, which has Conflicts: Makefile in it twice.
Can someone please point out how to do the above two actions in a simpler way? Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…