gap, my most loved git command

gap the alias I created, mapping to git add -p has been one of my most typed commands ever since I changed my workflow.

What this does :

It breaks up your diff into smaller chunks that help you avoid committing things you really don’t want to and helps you know exactly what code is going into the next command. For each chunk, you can choose to stage it or not. All staged changes are those that will be included in your next commit.

To add this command it opens your .bashrc in any editor and add this to it: alias gap="git add -p

It doesn’t matter if you use Git CLI or the app as you get the same things done, but if you really want to get comfortable with it, start using the terminal. It will be painful in the beginning, but you’ll learn more about Git this way.

Published by Dwain Maralack

Servant, Husband, Software Engineer and all round fun-loving guy, I work as a Developer at WooThemes.

Join the Conversation

2 Comments

    1. It has something to do with how close the changed lines are to each other. At times, if there are many lines change close to each other, it it shows you a big blob, but that is rare. If its mostly new code this is not helpful.

Leave a comment

Leave a Reply to Jonathan Bossenger Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.