Reputation: 77
I want aliases for:
git add --a
git commit -m ""
git push origin master
git pull origin master
I have made them all, except how do I have terminal prompt me for a commit message, and then store it?
So:
commit
"What's your commit message"
added footer <enter>
git commit -m "added footer"
Is that possible to do?
I tried doing a printf
and read
variable, and then inserting that with $variable
but it didn't work.
Upvotes: 0
Views: 334
Reputation: 4205
This is what I personally use in my .bash_profile:
commit(){
git commit -m "$*"
}
alias gc=commit
Simple and sweet.
$ gc This is a really long commit message
Upvotes: 1
Reputation: 21460
You can do it via a function instead of a single alias:
commit () {
echo "What's your commit message?"
read a
git commit -m $a
}
Though, even in this case, you won't be able to have commits longer than a line. If you want more than that (and it is recommended that you do this), you should open an editor with a temporary file and use that.
Upvotes: 1
Reputation: 15350
Use functions instead of aliases:
#!/usr/bin/env bash
commit(){
echo "What's your commit message?"
read msg
git commit -m "$msg"
}
Upvotes: 4