I did a stupid thing; I did 'git fetch' on local repository that was not committed. So my files now overwritten by it. How I can restore my plight that was before this stupid mistake?
things that I've done:
Just performing a git fetch
doesn't touch the working tree. ( git pull
would try, because that does a fetch
followed by a merge
, but that's a different matter.)
It looks like you have committed the changes though - but then confused yourself afterwards (which can be easy to do with git, certainly...)
Fortunately, git reflog
is your friend: it will show you everything you've done, including the commit hashes along the way. Run it and find the commit you want to get back to, then use git reset --hard <commit>
to get back there. You can then merge the fetched changes, or rebase, or whatever it is you want to do.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.