Bash Scripting Shortcuts: Pushing All Changes in Git
created: Jan. 28, 2017, 6:17 p.m.
I cannot count how many times I entered these commands:
git add -A git commit -m "Some commit message" #Sorry I don't use vi to write commits git push origin master
I thought there has got to be a way to make this easier when I just want to commit everything into my master branch. Then I remembered, "Hey, why not write a bash script?". So that is what I did.
COMMIT_MESSAGE = $1 #Accepts a string argument ./push_everything.sh "Commit Message" git add -A git commit -m COMMIT_MESSAGE git push origin master
And whala! We have a script that instantly commits everything into the master branch. You may even extend this script by doing this.
COMMIT_MESSAGE = $1 BRANCH_TO_PUSH = $2 git add -A git commit -m COMMIT_MESSAGE git push origin BRANCH_TO_PUSH
This one enables you to choose which branch to push to:
./push_everything.sh "Commit Message" <Branch>