Shell script helper for git commits Shell script helper for git commits bash bash

Shell script helper for git commits


You must quote the variable in your script.

#!/bin/bash -ecommit_message="$1"git add . -Agit commit -m "$commit_message"git push

I also set "-e" so that if there are any errors, the script will exit without processing subsequent commands.

As to your second question, the . in the script should refer to your current working directory, as you intend. However the -A is causing it to add all files that have been modiied in the repo.


You can create alias with argument. Something like:

[alias]  cap = "!git add . && git commit -m '$1' && git push origin"


with and Alias I couldn`t put variables in the middle of the sentence, but you can create a function and put it on your .bashrc like this

commit(){  git add --all . && git commit -m '$1' && git push origin master}