Doug Doug - 6 months ago 17
Bash Question

Chaining system commands onto git commands

I'm trying to chain system commands in bash onto my git commands.

For instance:

git commit -m cat commit_message.txt
.

I've noticed I use the exact same 4 commands repeatedly, and I'd like to create an alias that does:

git add -A && git commit -m cat ~/my_project/commit_message.txt && git push origin dev && git push heroku-staging master
.

I like to keep a log of the changes I make to my app in my commit_message.txt file, and update it each time I make a change, so it'd be ideal if I could just read this log from the terminal every time I want to commit a change.

I am by no means a terminal wizard, so I'm hoping this is an easy solution that I haven't come across yet. I've searched quite a bit, and haven't found a similar use.

Answer

git commit has a -F (--file) that does exactly what you want, without using any shell magic: just use git commit -F commit_message.txt.

Comments