Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
638 views
in Technique[技术] by (71.8m points)

version control - Git Interactive Merge?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...