Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git, lost my changes

Tags:

git

this prolebme is mainly because of bad wifi connection in the cafe I am in. I did a number of changes on my local repo, eveyr time I did one I would push properly. The latest one I did the Internet connection was on and off, so It did push and git log would show the commit , but git status showed a discrepancy between my local and remote.

Since my last push was a success, I thought I would do this

git fetch origin
git reset --hard origin/master

But crap, this got rid of all commit I did today and head is now some commit I did yesterday, and when I go to bitbucket to see the repo it doesn;t even show today's changes.

Someone please tell me I didn't just screw myself over? is there a solution for this?

like image 514
Eddie Avatar asked Dec 15 '22 04:12

Eddie


1 Answers

Check the git reflog to see commit hashes for all your recent activity.

Git won't garbage collect unreachable commits for at least 2 weeks (unless you explicitely tell it to)

Alternatively, git log -g might help you:

-g, --walk-reflogs

Instead of walking the commit ancestry chain, walk reflog entries from the most recent one to older ones.

like image 166
Gareth Avatar answered Dec 31 '22 13:12

Gareth