Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: how to accept "theirs" version of a submodule conflict?

In case of a submodule conflict (i.e. when the two commits to merge contain different changes of the referenced commit), how can I easily set the submodule to "theirs" commit? In case of files, I would perform:

git checkout --theirs <file>

However this does not work for submodules. On a more technical level, what I have is an Index containing the submodule for stages 1, 2 and 3:

$ git ls-files -s module
160000 89b085c4269259fa22632353071e6875f158afde 1       submodule
160000 b9ad3bc8aafdf52a2adf74620afae8934474b82d 2       submodule
160000 1afd42893d18ef5edeeadd67e7c65262505e6004 3       submodule

and what I want is to have the "theirs" version in stage 0:

$ git ls-files -s module
160000 1afd42893d18ef5edeeadd67e7c65262505e6004 0       submodule

Update: false assertion on reference http://fiji.sc/wiki/index.php/Git_submodule_tutorial removed.

Update 2: Index-related example added.

like image 706
mstrap Avatar asked Jun 28 '12 10:06

mstrap


1 Answers

Your parent repository just refers to the current working version of your submodule repository. The "submodule pointer" always points to the working copy of the submodule.

So you have to put the submodule repository in the state you want to (in this specific case, by updating it to "theirs" version). After that, the "submodule pointer" will update itself automatically (of course, you'll have to commit the change).

like image 86
penartur Avatar answered Sep 18 '22 22:09

penartur