Git merge - handle any automatic file change as a conflict (do not stage) like --squash

I am merging a large series of expanded tags from master into a theme branch and using:

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

      

And it works as it should. Apart from the hard file conflicts being generated, I need to view and edit a large number of files that have incorrect automatic merges, due to the person having to figure out the correct strategy (e.g. during git add -p filename).

So firstly, is there a way to prevent the automatic creation of any (all) files in the merge?

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

+3


source to share


1 answer


Is there a way to prevent the automatic creation of any (all) files in the merge?

Yes. Use git merge --no-ff --strategy=ours

to leave un-op merge uncommitted, this baseline for manual roll merge, then use git read-tree

merge setup to do all of the low-level adjustments except conflict resolution, choosing the options for which you want them to handle 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 only makes all changes for one branch, but leaves anything with a conflict hint for you.

You can get three different versions of each file, which should be merged 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 docs

When you're done with all your git manual permissions shouldn't be touched at all, you can clean up with git 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 docs merge-index

+3


source







All Articles