0

I attempted to pull, but git complained about local changes being overwritten so I stashed and pulled. By pulling, I wrote over a file that I now want to revert back to how it was when I stashed it. How can I do this? When I run git git stash show it shows the single file is still there.

I want to keep all other pulled changes in my local repo, I just want to get that single file back to its old state. Thanks

displayName
  • 195
  • 2
  • 15
  • If I got your question right then do `git stash pop`, but this might cause some conflict where you have to resolve the conflict and then do `git reset FILE` the file. – ROOT Mar 13 '20 at 18:30

1 Answers1

2

There are several ways. One simple one would be

git checkout stash -- path/to/the/file

This will copy the file from the stash to your index and working folder. This will replace whatever is currently in your index and working folder; if that's just a version you checked out from the remote and dont' currently want, it's fine, but to be clear: Even if you have changes in the current worktree file that have never been committed, this would overwrite them and they would never be recoverable. So use due discretion with this command.

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52