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.

tarsius
  • 25,298
  • 4
  • 69
  • 109
Gina
  • 153
  • 6

3 Answers3

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.

elemakil
  • 2,517
  • 1
  • 18
  • 26
  • Installed with el-get and the docs are great. Thank you! – Gina Oct 03 '14 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 06 '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.

tarsius
  • 25,298
  • 4
  • 69
  • 109
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.

ideasman42
  • 8,375
  • 1
  • 28
  • 105