Let's say in a git repo I have a file containing version information:
version=42
Now if on two separate branches the version is incremented to
version=43
and these branches are merged, the standard merge mechanism of git would not yield a merge conflict, since both versions are the same (even though the merge base is different).
Normally this is wanted behavior, but in the case of this file I want to get a merge conflict whenever both branches differ from the merge base. Is there any merge strategy that always ends in a merge conflict when a line is edited in both branches (even if they are the same)?
Often, merge conflicts happen when people make different changes to the same line of the same file, or when one person edits a file and another person deletes the same file. You must resolve all merge conflicts before you can merge a pull request on GitHub.
The most common merge conflict scenario occurs when you pull updates from a remote branch to your local branch (for example, from origin/bugfix into your local bugfix branch). You can resolve these conflicts in the same way: create a commit on your local branch to reconcile the changes, and then complete the merge.
No. In fact, not only is there no such strategy built in to Git, the rest of Git's support routines—which you might want to use to write such a strategy—don't help you out here. Existing merge drivers mostly use git read-tree
(or its internal equivalent) to perform as much of the work as possible inside the index, and it's git read-tree
itself that collapses such results back to a fully merged stage zero entry, saving having to re-code that same thing into the recursive and resolve merge drivers.
The culprit code is here.
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