JobHunter69
JobHunter69

Reputation: 2280

How do I retrieve my changes that I did not push to a remote repository in Git?

I made major edits to a file, but I did not realize that someone else had renamed it. I pulled after making edits to the file (because there was a collision with pushing), so that file became deleted. How can I recover it?

When I check git status, it says that my branch and origin/master have diverged, and also "Changes to be committed" include the file that was deleted on accident.

Upvotes: 0

Views: 925

Answers (1)

zavolokas
zavolokas

Reputation: 707

You can first run $git reflog that will show you a list of commits. Just find the one you wont to restore and note its hash. Than run $git reset --hard <hash>. Your file will be restored.

After that I would put your commit that contains the major edits before the commit that renames the file using $git rebase

Upvotes: 2

Related Questions