DEV Community

loading...

Partial Commits with Git

Jesse Phillips
Senior Quality Assurance (SDET) ¶ Avid hobby D programmer ¶ Telling people what to do because I am right.
Updated on ・1 min read

I had some success bringing better commits to our repo.

I happened across a post like this one.

See I don't really like emoji and people can go overboard, but others do like it so when you give them a dashboard like gitmoji and tell them to add emoji to their commit message, you start to talk about all the emoji in the message, your commit should only need one...

Which brings me to the partial commit. See git has a staging area which is completely separate from the working tree. Many know you can stage files and leave others uncommitted.

With the right tool (git gui) you can stage just one line. When I first brought up splitting the commit, the reaction is fear because their is so much pain in the stash and edit to break them up. Why would they expect to be able to control lines when UIs don't make the feature obvious and it isn't mentioned in git training.

Discussion (5)

Collapse
dahnielson profile image
Anders Dahnielson

This is why I just love to use GitKraken as my GUI Git-client. I have definitely become more productive since I switched from CLI Git to GitKraken as it's so easy to drill down exactly what lines to stage for a commit.

Collapse
maniflames profile image
Maniflames

I ran into a situation today where I had to split changes from one file into seperate commits and you are definitely right. Really good timing :)

Collapse
jwollner5 profile image
John 'BBQ' Wollner

I would like to know more about partial commits to the line level - that would be handy on some projects

Collapse
jessekphillips profile image
Jesse Phillips Author

mfranc.com/blog/git-git-gui-stagin...

Git add -p is the command line feature for it (I don't use it.)

Collapse
jessekphillips profile image
Jesse Phillips Author

Sorry I misread this with the first reply. What in particular do you think you don't know?