Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git submodule not ignored even with ignore=all

We have a main git repo in which we have added another repo as submodule. We have configured to ignore any changes to this submodule by setting ignore=all in the .gitmodules file with the expectation that any changes within the submodule (commits or files) never show up as changes when adding files to staging.

What we are observing is that even though the submodule doesn't show up as changed when we run git status, using git add -A adds the submodule as a change if there is difference in the commits in the submodule between the current branch and master.

Is there a way to avoid the submodule from being added to staging/commit when using git add or git commit -am?

like image 263
Darshan Avatar asked Dec 28 '25 16:12

Darshan


1 Answers

The workaround is to use update-index -assume-unchanged.

git update-index --assume-unchanged path/to/submodule

You can issue this command for multiple sub modules.

You can use following script to add all submodules to the ignored index

grep 'path =' .gitmodules | awk '{print $3}' | xargs git update-index --assume-unchanged

(based on another answer)

like image 153
koppor Avatar answered Dec 31 '25 07:12

koppor