Take the 2-minute tour ×

Since gitmodules were introduced in Git, I like to add them like so:

[submodule "actionbarsherlock"]
path = actionbarsherlock
url = git://github.com/JakeWharton/ActionBarSherlock.git
ignore = dirty

The important part here is ignore = dirty.

When using the git submodule add command, I'm forced to add this line by myself in the .gitmodules file.

How can I make this the default behavior for every git submodule add I'll make in the futur?

I know about the submodule.<name>.ignore configuration, but how to apply it to all by default?

share|improve this question
Don't know if there's a way to do this by default, but you could easily add an alias or script to do it for you. –  Christopher Oct 31 '12 at 17:22
I don't see how to do that by alias. And as for script, I just hoped git had a default option for it –  shkschneider Oct 31 '12 at 17:25
Git will treat as an alias any script in $PATH that starts with git-<command> as git <command>. You could just write a shell script that accepts the submodules name, adds it, then issues the submodule.<name>.ignore configuration and just call it git supersubmodule or something. –  Christopher Oct 31 '12 at 17:38
@Christopher I know I can do that, so they really are no git options for it? Please post an answer with your last comment if so. –  shkschneider Oct 31 '12 at 17:39
add comment

3 Answers

I'm not sure about a default option. Were it a binary state (ignore or not), you could get traction with:

   Sets the default value of --ignore-submodules. Note that this affects only git diff Porcelain, and not lower level diff commands such as git diff-files.  git checkout also
   honors this setting when reporting uncommitted changes.

But as you're using dirty I'm not sure there's a way to set a default. Regardless, you could do this with a git alias in your $PATH. Write a script that accepts the submodule as an argument and set the proper dirty configuration value, then add that script to your $PATH. Call it git-<command> and it'll be available as git <command>.

share|improve this answer
Ok, I know options for diff and status, but would like a better thing. A script is a posible option. –  shkschneider Oct 31 '12 at 17:46
This is a good candidate for the git list. THey could give you a definite answer, and if that answer is "no", a patch might be proposed. –  Christopher Oct 31 '12 at 17:49
add comment
up vote 0 down vote accepted

So to close this, no, there is not default option for it (sadly).

share|improve this answer
add comment

Do you mean this?

git config --global core.ignore dirty

which writes the preference to your ~/.gitconfig file.

share|improve this answer
I don't think it works. At least it's not working for me (git 1.8.5). –  Paweł Gościcki Nov 29 '13 at 13:18
add comment

Your Answer


