Hacker News new | ask | show | jobs
by johnisgood 654 days ago
Wow, I have been using git for ages but I did not know about this. I was relying on magit (for Emacs) and git-cola.
2 comments

Magit does interactive staging (and unstaging) a lot better than git itself does.

In d u, you can “s” on a file or hunk and it’ll stage just that. And if you select lines (c-spc?) it’ll stage just those lines.

To unstage, go to d s and use “u” the same way.

The massive advantage aside from line-wise staging is that you don’t need to stage linearly.

You can also discard changes that way, e.g.:

    git checkout -p -- .
I will have to read about how to use it, because it shows some hunks on a page, and I do not want to stage all of them, for example.
When it shows you a hunk that's bigger than you like, you can use 's' to split it into smaller hunks.
Thank you!
Cherrypick (-p) is wonderful. A command I also like is rebase interactive(-I)

Git rebase -i HEAD~[number of commits]

Yeah, I use `git rebase -i HEAD~n` a lot.