1

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?

1
  • 1
    It 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. Commented Jul 24, 2020 at 2:38

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.