DEV Community

Cover image for Git staging with Tig
Samuel Abreu
Samuel Abreu

Posted on

2 1

Git staging with Tig

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.

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay