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.

1

3 Answers 3

13

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.

2
  • Installed with el-get and the docs are great. Thank you!
    – Gina
    Oct 3, 2014 at 15:44
  • 1
    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, 2014 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.

0

Since I don't want to accidentally loose any edits in buffers I have open, I have a key bound to revert all buffers, I just run this command when making large changes to the repository which Emacs's wont be tracking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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