Gopal Joshi
Gopal Joshi

Reputation: 2358

Recover files which are added but not commited

I am using git version control system in my project. Today after completing my work, I have added all the files using

git add [file-name]

and then forget to commit changes to server, I have pulled and pushed commands as below

git pull --rebase origin [branch-name]
git push origin [branch-name]

After a minute I got that I have forgot to commit (using command git commit -m "comment") changes to server. Now, is there any way to get my changes back? I've already googling and tried find similar issues on Stack Overflow but could not get satisfied solution.

Upvotes: 3

Views: 71

Answers (1)

javier_domenech
javier_domenech

Reputation: 6273

This question has been already answered on SO here

For what I understand of what knittl says, you should execute git fsck --full --unreachable --no-reflog to get a list of objects (blobs or trees) and then read the objects with git cat-file -p <object hash> until you find what you need.

For trees, you have to use git commands: git read-tree.

Upvotes: 1

Related Questions