GitHub deleted my previous commits
Please! I lost all my day's work.
I created a github repository... I've been working all day doing git add -A and commit but I never did a push. I changed a readme directly on the page (not knowing I was going to have problems to merge those same branches).
When I tried to make git push after all day's rok the following happened:
To https://github.com/NEGU93/Steganography.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/NEGU93/Steganography.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
So I tried ta git pull --rebase
but it started crashing some things I don't know what it is:
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/NEGU93/Steganography
6161279..44d1f0f master -> origin/master
0 [main] expr 8516 open_stackdumpfile: Dumping stack trace to expr.exe.stackdump
0 [main] cat 15632 open_stackdumpfile: Dumping stack trace to cat.exe.stackdump
0 [main] rm 4660 open_stackdumpfile: Dumping stack trace to rm.exe.stackdump
^C
I put ctrl+C to stop the crashin there. So I made a git fetch
and then a git push of my work:
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>
So I did as suggested and made a git push to master:
git push origin HEAD:master
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 1.49 KiB | 0 bytes/s, done.
Total 5 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/NEGU93/Steganography.git
44d1f0f..c3b8393 HEAD -> master
But now when I got back the work was not there... Help! I don't know what to do and I'm starting to panic. I think the problem is with git fetch. Is there a way to get all my work back???
Use git reflog
to see past commits, then use the commit's hash to reset hard eg:
git reset --hard e870e41
See How can I recover a lost commit in Git?
链接地址: http://www.djcxy.com/p/3976.html上一篇: 我该如何放弃Git中未分配的更改?
下一篇: GitHub删除了我以前的提交