igoren
igoren

Reputation: 111

Restore Files From After a Commit on GitHub

I have worked on my files for few days without committing.

Today I worked with the GitHub client, don't know what I exactly did but all my files were restored to an old commit.

And than, without understanding that my files have just changed to the old commit, I committed my files - thinking I am committing most updated files.

All of my work from the last few days disappeared.

How can I restore my work?

Upvotes: 0

Views: 145

Answers (3)

Jepessen
Jepessen

Reputation: 12415

IF you've committed your work locally, even if you created some problem in push-pull with a remote repository, you should be able to recover something from the reflog command.

Upvotes: 0

David
David

Reputation: 3055

Git is much different from other VCS. You should commit as often as possible: that is every time you reach a point you're somewhat satisfied. Git gives you the chance to review, change, squash your commits and much more before sharing your changes with others.

But if you haven't committed, the only chance you have is to look to some filesystem tool to recover deleted files.

Upvotes: 0

SomeKittens
SomeKittens

Reputation: 39532

The big lesson here is:

Commit early, commit often.

If you restored an earlier state (I'm not sure how the GH client does this, but probably through git reset) without committing, your work is gone.

Upvotes: 4

Related Questions