The question is about Magit major mode for Emacs function and less so about how to do this via command line interface.
I only have a local Git repository. How would I restore a selected file to its previous version? I believe that the Git command for this must be something like git checkout HEAD^ path/to/file
but I may be wrong here too, just guessing really.
What I'm looking for is essentially the same thing as C-x v u in vc-dir
buffer.
Essentially, what I was hoping to do was:
delete the modified file.
pull from local repo.
But Magit doesn't seem to be able to do that, it seems to prefer to just delete the file, instead of restoring it.
*magit-status*
)? (2) If you only want to revert to base, why not use thevc
minor modeC-x v u
? – Feltnergit checkout HEAD file
would discard uncommitted changes.git checkout HEAD^ file
would also revert changes (if any) made to the file in the most recent commit to the repository. If that commit did not involve the file in question, then the^
is effectively redundant. Going by your "delete and pull" summary, you just want to discard uncommitted changes, in which case Rémi's answer is the one you want. – Lordly