Prevent updating git submodule commit

Answered

I am using submodules for one of my projects. It works great and I like that I can point all repos to the same branch, but there is one thing that bothers me every time. After each commit to the submodule, the commit id in the main repo is updated. Is there any way to prevent this behavior? I want to update commit only when I create a new release of my product, not on every commit.

0
5 comments

Could you please provide a bit more details.

Do you sue git submodules (with the appropriate git command), or you just mean some module of your project?

And what do you mean commit ID is updated? Commit hash changes? Something else?

A screenshot is appreciated.

0
Avatar
Permanently deleted user

I am using proper git submodules. Every time I commit something to my submodule, I get something like this:

> git diff
diff --git a/traccar-web b/traccar-web
index 9dc4e2a..6d44721 160000
--- a/traccar-web
+++ b/traccar-web
@@ -1 +1 @@
-Subproject commit 9dc4e2a38b872f4dd0ba51a821fc2052ab9323f7
+Subproject commit 6d447219ceab19c368b7ca6efabca83001b64a04

As far as I understand, it means that commit hash of the submodule is updated in the main repository. I want to avoid updating it with every commit to submodule.

0

This is the expected behavior of git-submodules.

In the main repo a submodule is represented as a particular commit from the appropriate repository

See official docs for details

https://git-scm.com/book/en/v2/Git-Tools-Submodules

0
Avatar
Permanently deleted user

Thanks. I have found a way to ignore changes to submodule. I have added following line for the submodule config:

ignore = all
0

I just add here that Anton is right, if you want to stop generating those submodule hashes, add to your .git/config

[diff]
    ignoreSubmodules = all
1

Please sign in to leave a comment.