5

When I'm viewing a file and then pop a stash which modifies that file in the working tree using git stash pop in either bash or eshell, what is the best way to immediately see those changes in the buffer visiting that file?

Usually I end up using C-x C-f or M-x revert-buffer but that's a bit slow. It would be nice to find a mode that automatically updates buffers when the files they visit change on disk.

I've heard of git-modes for viewing diffs or conflicts, but haven't found much for stashing/popping or cherry-picking.

11

If you use magit you can create a stash with the z z command from the magit-status buffer. You can also pop a stash using the A command.

If you use these commands, affected files will be automatically reverted (changes are loaded).

Check out the magit documentation for more info on how to use magit effectively.

  • Installed with el-get and the docs are great. Thank you! – Gina Oct 3 '14 at 15:44
  • I usually prefer to use a instead of A so I don't loose the stash until I'm satisfied with the result. Then you can kill the stash – Willyfrog Oct 6 '14 at 21:48
0

As mentioned by @elemakil running a Magit command causes buffers that visit files inside the same repository to be reverted when they change on disk.

This mode only does something after you have used a Magit command. If you run a Git command in bash or eshell then magit-auto-revert-mode does not kick in.

However that mode is just a specialized variant of global-auto-revert-mode. The latter works regardless of what causes a file to change on disk.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.