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?
Today I found out that can use
git config
to change the.gitmodules
file, and therefore can add the ignore dirty flag without going into the file and adding the line by hand:In my case, I was able to automate the two steps in a script with that command.
Do you mean this?
git config --global core.ignore dirty
which writes the preference to your
~/.gitconfig
file.I'm not sure about a default option. Were it a binary state (ignore or not), you could get traction with:
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 properdirty
configuration value, then add that script to your$PATH
. Call itgit-<command>
and it'll be available asgit <command>
.So to close this, no, there is not default option for it (sadly).
Note that even if there were such a config, git 2.0.1 (June 25th, 2014) would still show you a submodule which has been staged.
See commit 1d2f393 by Jens Lehmann (
jlehmann
)See also commit c215d3d for the
git commit
part.