Boost your Git productivity in 3 simple steps

·

4 min read

Version-control system is one of the most essential tool for developers. Especially if you work in a team.

As we gain experience over the years of working as a developer, we tend to hate doing repetitive tasks. We want to automate everything as much as possible, making our work faster and more efficient.

Doing Git commands is too tiresome. I do it a few times every hour. And I have to do it slowly and carefully because I don't want to mess up our code. If we could just make it faster. Even just a few seconds will make a huge difference.

Luckily for us, there is a way.


  • Go to your users folder. In my case, it is in C:\Users\VJ.
    Create a file called .bashrc image.png No file name. Just the extension.

  • Write the following commands in the file:

      alias gco='git checkout'
      alias gpl='git pull'
      alias gplo='git pull origin'
      alias gps='git push'
      alias ga='git add .'
      alias gcm='git commit -m'
      alias gpsu='git push --set-upstream origin'
      alias gfdevt='git pull && git pull origin development && git push'
      alias gmdevt='git checkout development && git pull && git pull origin my-branch-dev && git push && git checkout my-branch-dev'
    
  • Restart your terminal. If you are using Visual Studio Code, just close the integrated terminal then open it again.


Now, you can use these new commands.

Instead of writing:

    git pull origin development

that takes me up to 5 seconds, I can just write:

    gplo development

that takes me up to 3 seconds max.

Instead of writing:

    git commit -m 'updates for task #123'

We can just write:

    gcm 'updates for task #123'

And if we are doing our first push for a newly-created repo, we always forget this command:

    gpsu master


By reducing our commands to just 3 to 4 letters, we can surely save a lot of time in the long run.


We can also shorten long commands such as merging from other branches.

    alias gmdevtostg='git checkout staging && git pull && git pull origin development && git push'
    alias gmstgtoprod='git checkout master && git pull && git pull origin staging && git push'


My example of pulling updates from dev, then merging my changes from my branch to dev.

    gfdevt
    ga && gcm 'updates for task#123' && gps && gmdevt


Thanks for reading up to here. If you have questions or see any corrections, and also if you know to do it for other OS, please feel free to share in the comments.