Git交互式合并? [英] Git Interactive Merge?
问题描述
我有两个分支完全相同的文件(因为你想知道它是一个.sql文件),我想以交互方式合并它。
几乎我想要在发生冲突(或命令行)时打开diff程序,并准确选择哪些行到哪里。
有没有办法做到这一点?
是的,但主要是通过手动实现。你会告诉Git你合并了两个相关的分支,但它不应该尝试单独提交结果,(编辑以添加:,如果它认为合并)
$ b $ pre $ g $ git merge --no-commit --no-ff分支合并
然后你会问这个文件,因为它出现在两个分支中:
git show HEAD:filename> filename.HEAD
git show分支合并:文件名>文件名.branch
及其合并基础,
git show git merge-base HEAD branch-to-merge`:filename> filename.base
你可以用你想要的任何工具合并它们(例如)。
$ $ $ $ $ $ $ meld filename {HEAD,branch,base}
您会将它放到( git add filename
) ,然后提交合并( git commit
)。
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?
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
).
这篇关于Git交互式合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!