Reputation:
Is there a way to set a global setting for git where you can specify it to to do particular prefix before every time I do something?
Say whenever I am commiting anything, I want to set a global setting in git where -S
would be executed every time I commit anything.
Is there a way to do this? If yes, how?
Upvotes: 0
Views: 374
Reputation: 45649
You can't generally change the default options for a command.
In many cases - including your example, and a lot of the cases where it makes sense to want to change the default behavior of a command - you can set options in git config
. It's not one general option to modify the command line, which seems to be what you're asking; but rather for any given behavior, there is likely a config option that sets that behavior specifically. See the git config
docs for a list of available options.
Also, you can generally create aliases (see git alias
) to make them equivalent to a command with particular options.
Upvotes: 1
Reputation: 1902
You can do this
git config --global --add commit.gpgSign true
or in ~/.gitconfig
[commit]
gpgSign = true
Refer man git-config
for other useful variables that you can utilise.
Upvotes: 0
Reputation: 690
It is not possible to override a built in command, and not possible set default arguments for them either. However, for this specific case, you can easily create an alias In your ~/.gitconfig
Add something like this:
[alias]
commits = commit -s
should do it.
Which you would then use like this:
git commits
Upvotes: 0