I have local changes made, and I run "git pull". My local files were overwritten by one remote commit. Is is possible for me to recover those uncommitted changes?
Asked
Active
Viewed 953 times
1
-
1It might be possible if you have some other sort of backup, but git cannot recover anything except a commit. If your local changes were not committed (or stashed, which is a form of committing), they do not exist as far as git is concerned. – matt Jul 24 '20 at 02:38
2 Answers
0
Local changes should (not yet add/committed) not be overwritten by a git pull
(unless you did git pull -f
)
I always prefer the autostash feature
git config --global pull.rebase true
git config --global rebase.autoStash true
If your changes were added to the index before the pull, you might check git fsck.
If they were actually committed, you can restore them from git log.

VonC
- 1,262,500
- 529
- 4,410
- 5,250
0
git pull
alone should not delete content without warning.
If the autostash
option (mentioned by @VonC) is turned on on your machine, your changes may have been stashed away :
run
git show stash
to view the content of the latest stash,if you changes do not show up in the latest stash, check :
git stash list # to have an overview of what is stored in the stash git stash show stash@{n} # to view the content of a previous stash
If you find the content you are looking for in one of the stash entries, you can run :
git stash apply
# or
git stash apply stash@{n}
to recover them.

LeGEC
- 46,477
- 5
- 57
- 104