A Useful Git Command

A Useful Git Command

Read 153 times

#git

#github

#tip

As a developer version control is something that is most likely in your wokflow. If not, you should really consider taking the time to incorporate it.

The most common git commands are

But there is one more command, that no one told you about, one that is a game changer.

Enter git add -p

In most instance when you make changes to your file, you use git add to stage those files and then git commit -m to save them to source control.

Let’s what happens with git add -p:

commis.png

From the screenshot above:

If I had made more changes, It would show me the changes one by one and ask me whether I want to stage them or not

morecomm.png

After staging your changes, all that’s left is to commit them.

Conclusion

I am sure you can see how useful this could be to keep proper track of the changes you make during your development flow and decide what to stage or not.

Much better than going git add [filename], no?

I write this article partially because whitep4nth3r was on the fence about writing about it.


Thank you for reading, let’s connect!

Thank you for visiting this little corner of mine. Let’s connect on Twitter, Polywork and LinkedIn

Back to articles