Simple Bash Script to Commit and Push to Git

Share This Post!
Share on FacebookTweet about this on TwitterShare on LinkedInShare on Google+Email this to someone

A quick git bash script for you guys!

If you are like me and value simplicity and hate remembering stuff then this simple git bash script to commit and push your code to both local and remote git repositories is for you. I am using GitLab to host my remote repository.

Setting Up a Local git Repository and Pushing it to a Remote Repository

git init
git add -A
git commit -m "first commit"
git remote add origin git@***your repository***
git push -u origin master

git bash script

Now, simply save the below script in a file called commit.bash, making sure to change the first line to point to where your code lives.

#!/bin/bash

cd /Users/alex/Documents/DEV
git add -A
if [ $# -eq 0 ]
then
  git commit -m "nothing to see here"
else
  git commit -m "$*"
fi
git status
git push origin master

Then add executable permissions the saved file:


Enter your email below and receive everything you need
to get started with coding! ALL 100% FREE!

chmod +x commit.bash

Then hack away with your code. When you are ready to commit and push your code to git simply run your git bash script!

./commit.bash cool stuff

Happy coding!

Share This Post!
Share on FacebookTweet about this on TwitterShare on LinkedInShare on Google+Email this to someone