Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git submodule merge conflict: how to visualize?

I was pretty happy when I found out lately about

git submodule summary

which shows me nicely by which commits the checked out commit of a submodule is ahead or behind the reference in the repository.

Now when I am in the middle of a merge with submodule conflicts, the same command does not produce useful output. I need a painful sequence of gitk in my main tree examining the branches, along with cd'ing into the submodules, fetching and gitk in there, comparing sha1 values...

What would be a more convenient way to get the picture of the conflict?

like image 485
chrisxxx Avatar asked Jun 08 '11 16:06

chrisxxx


People also ask

How do you view a merge conflict?

To see the beginning of the merge conflict in your file, search the file for the conflict marker <<<<<<< . When you open the file in your text editor, you'll see the changes from the HEAD or base branch after the line <<<<<<< HEAD .

How do I see merge conflicts in Visual Studio?

If there are any merge conflicts when you're pulling changes or trying to merge two branches, Visual Studio lets you know in the Git Changes window, in the Git Repository window, and on any files that have conflicts. The Git Changes window shows a list of files with conflicts under Unmerged Changes.

How do I see a merge conflict in a pull request?

Pull the most recent version of the repository from Bitbucket. Checkout the source branch. Pull the destination branch into the source branch. At this point, pulling the destination will try to merge it with the source and reveal all the conflicts.

What happens if you get a conflict during a merge?

During the Merge Process The failure during the merge process indicates that there is a conflict between the local branch and the branch being merged. In this case, Git resolves as much as possible, but there are things that have to be resolved manually in the conflicted files.


1 Answers

You can make a script. Here is the core of such a script:

 git --git-dir=submodulepath/.git diff \
    $(git ls-tree HEAD submodulepath | cut -c 15-54) \
    $(git ls-tree MERGE_HEAD submodulepath | cut -c 15-54)

you can replace diff with log or any number of other commands that will help you see what the changes are. One would be to see if it would be a fast-forward merge in which case you can resolve the conflict quickly without merging at the submodule level.

There is also gitslave which will help you with such issues.

Hope this helps.

like image 110
Adam Dymitruk Avatar answered Oct 16 '22 18:10

Adam Dymitruk