Git合并 - 将任何自动文件更改视为冲突(不要分阶段),如--squash [英] Git merge - Treat any auto file change as a conflict (do not stage), like a --squash

查看:1121
本文介绍了Git合并 - 将任何自动文件更改视为冲突(不要分阶段),如--squash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一大组从主人打包的标签合并到主题分支中,并正在使用:

  git  -  no -commit --no-ff tagName ^ 0 

它的工作原理是 EM>。除了创建的实际硬文件冲突之外,我需要审查并手动编辑大量文件,这些文件由于需要人工来确定正确的策略而导致自动合并不正确(就像您在git add -p文件名期间所做的那样)因此,首先,是否有办法阻止合并中的任何(所有)文件的自动分段?



有没有办法做一个merge --squash,手动编辑文件(git add -p),然后在下一次提交时将其转换为MERGE_HEAD,以便提交两个父母,并成为下一个合并基础。

解决方案


有没有办法阻止自动登台任何(所有)文件在合并?


是。使用 git merge --no-ff --strategy = ours 让一个无操作合并未提交,这是进行手动合并的基线,然后使用
git read-tree 的合并设置可以完成除冲突解决之外的所有低级别准备工作,并选择您希望为其处理的情况的选项。

  git merge --no-ff --no-commit -s我们的主题
git read-tree -um $(git合并基础@主题)@ topic

git合并文档。 。 。 git阅读树文档



这是所有唯一一个分支变更的东西,但留下任何冲突的提示供您解决。



你可以得到每个文件需要合并的三种不同版本

  git ls-files -u \ 
| git checkout-index --stage = all --stdin

#做你不想在这里设置automerge的手动分辨率

git ls文档文档。 。 。 git checkout-index docs



当您完成所有手动解决方案后,git不应该触及所有您可以使用git的自动解析器清理剩下的 git merge- index -ao git-merge-one-file

  git merge-index -ao git-合并单个文件

#解决automerge找不到的任何冲突

git添加所有正确合并的文件you-havent-already-添加
git commit

git合并索引文档


I am merging a large series of unwrapped tags from master into a topic branch and am using:

git --no-commit --no-ff tagName^0 

And it works as it should. Besides the actual hard file conflicts created, I need to review and hand edit a large number of files that have incorrect auto-merges due to needing a human to determine the proper strategy (like you do during a git add -p filename).

So, first, is there a way to prevent auto-staging of any (all) files in a merge?

And is there a way to do a "merge --squash", manually edit the files (git add -p) and then actually transform that into a MERGE_HEAD on the next commit so that commit has two parents and becomes the next merge base.

解决方案

is there a way to prevent auto-staging of any (all) files in a merge?

Yes. Use git merge --no-ff --strategy=ours to leave a no-op merge uncommitted, that's baseline for doing a hand-roll merge, then use git read-tree's merge setup to do all the low-level prep except conflict resolution, selecting options for which situations you want it to handle for you.

git merge --no-ff --no-commit -s ours topic
git read-tree -um $(git merge-base @ topic) @ topic

git merge docs . . . git read-tree docs

This does all the only-one-branch-changes stuff but leaves anything with a hint of conflict for you to resolve.

You can get the three different versions of each file that needs merging with

git ls-files -u \
| git checkout-index --stage=all --stdin

# do the manual resolutions you don't want any automerge for here

git ls-files docs . . . git checkout-index docs

When you're done with all your manual resolutions git shouldn't touch at all you can clean up with git's auto-resolver for the rest with git merge-index -ao git-merge-one-file,

git merge-index -ao git-merge-one-file

# resolve any conflicts automerge can't figure for you

git add all-the-correctly-merged-files-you-havent-already-added
git commit

git merge-index docs

这篇关于Git合并 - 将任何自动文件更改视为冲突(不要分阶段),如--squash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆