DEV Community

loading...
Cover image for Git staging with Tig

Git staging with Tig

Samuel Abreu
・1 min read

After i saw a few posts here talking about tig, i installed and can't live without it anymore, the speed and VIM shortcuts kills any need for GUI clients i used in the past for specific tasks.

But the best feature by far is how easy it is to stage hunks of a file, i use print/Log/console.log/etc way more than i should and is very easy to forgot a useless/dangerous line on production code. Git have a ver useful feature to help commit only what it really needs to, git add --patch. And is here where tig helps me a lot.

Stage hunk

After opening tig, it presents you with the main view, showing the history, pressing "s" it shows the status view, where you can navigate through all staged/unstaged changes, review them and stage/unstage.

When you press enter on a file, shows a diff on the right/down and you can navigate it using "j" or "k" and Page Up and Page Down. Press "u" on the beggining of diff, it stages the entire file, but if you navigate to a specific hunk and press "u", only this hunk is staged, making it easier to left out all the unnecessary stuff you may include in the file while working on it.

Discussion (0)