Reputation: 743
I want to make a alias, like this below
gc this is a test message
convert to git commit -m "this is a test message"
.
How can I do this? I want that in my bashrc.
Upvotes: 8
Views: 4452
Reputation: 499
For anyone getting error: pathspec <commit message> did not match any file(s) known to git
, try this in your shell file:
alias gcam='git commit -am'
You should be able to use it like this with no problems:
gcam "potential fix - dup pageviews"
Upvotes: 0
Reputation: 3508
This should work:
alias ci = "!f() { git commit -m \"$*\"; }; f"
Unfortunately gc is already a subcommand and can't be aliased.
Upvotes: 1
Reputation: 5973
I have these alias in my .bashrc:
alias ga='git add'
alias gp='git push'
alias gl='git log'
alias gs='git status'
alias gd='git diff'
alias gdc='git diff --cached'
alias gm='git commit -m'
alias gma='git commit -am'
alias gb='git branch'
alias gc='git checkout'
alias gra='git remote add'
alias grr='git remote rm'
alias gpu='git pull'
alias gcl='git clone'
I normally commit with gm "msg"
Upvotes: 13
Reputation: 40739
bash alias
definitions don't take parameters.
Try using a bash function in your .bashrc:
function gc () {
git commit -m "$*"
}
Upvotes: 11