Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: another lost-everything example?

Tags:

git

I use git through the eclipse interface (since one year, not very confident, though).

I have a local repository that I push from time to time to a remote repository. Another developer is doing the same. Today I pushed the last 2 weeks changes to the remote repository. The push was rejected. As I know that the other developer is working on a different part of the application, what I did was a fetch of the remote branch and next a merge (click my branch and merge with the remote one). There was only a small conflict that I resolved, then I pushed again.

At this point, I discover that I've lost all changes in my local repository. In the history I can see only the last commits made by the other developers on top of my last push to the remote repository (2 weeks ago).

All my local history in the last two weeks is just gone. All changes gone. No recent logs. Tried with fsck, I see few files in lost-found. The other developer didn't do anything like rebase or similar, just push.

Any idea of what i did wrong, and more importantly, how to recover it???? Just some hint/guideline would be really helpful, I'm really under big pressure... thanks

like image 610
Glasnhost Avatar asked Feb 26 '26 05:02

Glasnhost


1 Answers

Try

git reflog

and see if it lists any of your commits. If it does, you can checkout the commit hash (say, a4b82)and create a new branch there:

git checkout -b new_branch_name a4b82

(And whatever you do, do not run "git gc" until you have found the commits and created a branch for them...)

like image 161
Aasmund Eldhuset Avatar answered Feb 27 '26 23:02

Aasmund Eldhuset