Вопрос

I have 2 repositories, "A" and "B", that share a 3rd repository "C" as a submodule inside "A" and "B".

My client is TortoiseGit.

If I commit and push a change in the submodule, and go to the parent repository ("A" for example), and right click -> commit in Tortoise, I can see the submodule folder marked as changed. If I commit and push that change, the main repository ("A") will be pointing to the correct/latest revision of the submodule. If I don't commit the change, the main repository will point to the revision of the submodule from before my update.

This is a bit confusing and sometimes causes problems when developers forget to update this pointer of the submodule in the parent/main repository.

So my 1st question is, how can I check, using the command line, which revision of the submodule is my main repository pointing to?

2nd question is, how can I manually edit that revision to point to any arbitrary revision of the submodule, and push that change?

Thank you

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

Решение

1)

I suggest you to use TortoiseGit GUI. Go to A/C -> TortoiseGit -> Show Log -> the revision in bold text is the one in working directory.

To check the submodule revision in working directory using command line,

cd A
cd C
git log -n 1

To check the submodule revision in current commit, go to A -> TortoiseGit -> Repo Browser -> select C and you can see the revision at bottom. You can also right click to show log or copy the hash.

But the command line way is not straight forward:

cd A
git diff HEAD~N HEAD -- C

where N is number of commits you think there is a change to submodule revision. The line +Subproject commit shows the desired submodule revision.

2)

  1. Make sure submodule's working dir is clean.
  2. Go to A/C -> TortoiseGit -> Switch/Checkout -> pick any revision -> OK
  3. Go to A -> TortoiseGit -> Commit -> ensure C is checked -> OK
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top