Doug Doug - 2 years ago 87
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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download