Skip to main content

Command Palette

Search for a command to run...

Scripts For Git

Published
1 min read
Scripts  For Git
J

Hi there, I'm Joy I'm a full stack developer, mobile application developer, Cyber security analyst, SEO analyst, trainer. Check my latest updates in www.joysam.me

Always tired of writing the same commands again and again for pushing your code to Git.

git add . 
git commit -m "commit_message"
git push

This reduces your developer experience. So let's make a shell script to follow the methodology of Do not repeat yourself (DRY). Even though you're not familiar with shell scripts, don't worry copy paste it still works.

Solution:

Create a Scripts folder


mkdir ~/Scripts/
cd ~/Scripts/

Create the Shell Script file

echo 'commit_message=$1
git add . &&
git commit -m "${commit_message}" &&
git push' >> Git.sh

Make an Alias

To make it more comfortable and to be accessed all over the OS

Mac Users

echo "alias Git='zsh ~/Scripts/Git.sh'" >> ~/.zprofile

Linux Users

echo "alias Git='bash ~/Scripts/Git.sh'" >> ~/.bash_profile

Now close all terminals and open them again to get the effect

Git "Now this is my custom commit message!!"

Life is good, but it can be better.