Reputation: 3771
This is my git alias configuration in the CONFIG file
[alias]
cm = "!git add .;git commit -m 'commit';git push origin master"
Instead to use 'commit' for every commit, I would like to specify it with something like:
git cm --'my commit text'
or
git cm 'commit text'
Even better, the argument should be optional, so that I can simply type git cm
to just make a commit with the text 'commit', but actually this is not a priority
Upvotes: 2
Views: 199
Reputation: 74695
If you're going to use positional parameters, I would suggest using a function:
cm = "!f() { git add .; git commit -m \"${1:-commit}\"; git push origin master; }; f"
The !
instructs git to run the command in a subshell. A function f
is defined, which uses either the message provided as the first argument or a default of commit
. The function is then called.
Use it like git cm "your message here"
or just git cm
to use the default.
Upvotes: 4