Вопрос

I am wondering if there any tools for providing a more verbose file history, especially with regard to merges where our changes are kept. This problem is best explained with an example.

Let's say I made a conflicting change on master and a feature branch:

git checkout master
<made some change to file.txt>
git commit -a -m "Change on master"
git checkout -b feature
<made conflicting change to file.txt>
git commit -a -m "Change on feature"

If I merge feature into master and keep my changes using git checkout --ours file.txt I get different results for file.txt than if I were to merge master into feature (and then merge feature into master to fast forward master). (I understand merging --ours effectively could have also been done inadvertently with mergetool.)

Using git log -p in both these scenarios, the merge commits do not report any change in file.txt, but its contents are different between the scenarios. Now file.txt's change history has been obfuscated and it has become difficult to know which version is in master. I can run git log -- file.txt, but this solution doesn't scale and requires you already know what files were part of the bad merge.

If someone makes the wrong merge decision, if becomes difficult to track down which files were kept the same. Otherwise, if a merge made changes to a file, it is easy to see this.

Это было полезно?

Решение

If the conflicts are getting resolved, they're just getting resolved incorrectly (per your comments on this answer), one way to see the differences in file.txt between two branches is with git diff:

git diff master feature -- file.txt

If you issue git diff master feature without any file specification, you'll see all the differences in all the repo's files. Creative applications of git diff will allow you to isolate nearly any changes you'd like.

Otherwise your best bet might be the merge commit itself. By default the commit message will output a conflicts section, which I'd advise against deleting.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top