I have two branches with the exact same file (incase you are wondering it is a .sql file) and I want to interactively merge it.
Pretty much I want to open up a diff program like I do when there is a conflict (or command line) and select exactly what lines go where.
Is there anyway to do this?
The interactive approach to merging two branches together (safely) is incrementally in steps that allows for manual fixing. Some call this “rebase with history” because the technique creates new commits based on previous commits like rebase, but retains the previous commit history (which rebase currently does not do).
Git merging combines sequences of commits into one unified history of commits. There are two main ways Git will merge: Fast Forward and Three way. Git can automatically merge commits unless there are changes that conflict in both commit sequences.
Yes, but it will mostly be by manually making that happen. You'll tell Git you're merging the two relevant branches, but that it shouldn't try to commit the result on its own, (edited to add: nor fast-forward if it thinks the merge is trivial):
git merge --no-commit --no-ff branch-to-merge
Then you'll ask git for the file as it appeared in the two branches:
git show HEAD:filename >filename.HEAD git show branch-to-merge:filename >filename.branch
and their merge base,
git show `git merge-base HEAD branch-to-merge`:filename >filename.base
You'll merge them using whatever tool you want (e.g.)
meld filename.{HEAD,branch,base}
you'll stage that (git add filename
), and then commit the merge (git commit
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With