Hacker News new | past | comments | ask | show | jobs | submit login

> because it allows easy staging of individual lines

I have been looking for this functionality for literally years at this point. Thank you! I will be trying this.




`git gui` and `gitk` my Swiss-knife tools for every day git-ting. They are maintained by git core team.


git gui says unknown command for me. gitk doesn't let you click on individual lines, and revert or add them as far as I could find.


Git gui is often in a separate package that you will need to install


Thanks - I eventually found it in the package repositories.

It does indeed have the same functionality as gitg for staging and reverting individual lines. It does have several UI niggles. For example when selecting it does not do so on a line by line basis, but instead character by character. But the operations are line by line, (or hunk). You also can't right click on file names and choose stage, revert, or delete.


git add -p


Not a gui, and rather painstaking. With gitg you single click on lines in changes (green added, red removed) which selects them. You can separately click on as many disjoint ones across as many hunks as you want. There is a 'Discard Selection' button which removes the highlighted lines from the code, and a 'Stage Selection' to add those lines to the index.

While git add -p is in theory doing something similar, it is a lot more painful to use, and you are still working a hunk at a time instead of just scrolling through changes.

I often use this functionality when I've made a number of changes during development and everything is now coherent, especially on a multi-language project. It is then easy to go in and discard lines that were added to debug, and stage lines across multiple commits so they are logically grouped.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: