你好,你可以 登入 weibo, github, 或 注册 成为我们的会员,来为大家分享.

branch - How do I manage conflicts with git submodules? - Stack Overflow (0)

git reset HEAD "SUBMODULE 名字"
git commit

REF https://stackoverflow.com/questions/826715/how-do-i-manage-conflicts-with-git-submodules

分享人 admin @ 2020-05-18 18:40:56

我也说两句:

登录以分享

What makes your situation kind of annoying is that git won't let you initialize an unmerged submodule, so the ordinary advice of just setting the submodule to the state you want within the submodule then running git add won't work. What you can do is to update the index directly, without going through the working tree.

One way to update the index is with git reset. If you know a commit in which the submodule is in a state you want, you can use that. For example, any of the following might be what you want:

git reset master -- sub
git reset master@{upstream} -- sub
git reset HEAD -- sub
git reset MERGE_HEAD -- sub

The other option is to update the index directly using the plumbing command git update-index. To do that, you need to know that an object of type gitlink (i.e., directory entry in a parent repository that points to a submodule) is 0160000. There's no way to figure that out from first principles, but you can figure it out from git ls-files -s or the following reference (see "1110 (gitlink)" under 4-bit object type): https://github.com/gitster/git/blob/master/Documentation/technical/index-format.txt

To use that approach, figure out the hash you want to set the submodule to, then run, e.g.:

git update-index --cacheinfo 0160000,533da4ea00703f4ad6d5518e1ce81d20261c40c0,sub