Re: Newbie: Restore messed up code from local or remote repository
- From
Ramkumar Ramachandra <artagnon@gmail.com>
- Date
- Nov 12, 2010, 10:38 UTC
- Message-ID
- <20101112103836.GB20053@kytes>
- In-Reply-To
- <1289550163511-5731540.post@n2.nabble.com>
Hi Greg,
gzoller writes:
Show 7 quoted lines
> git checkout > git pull -f /path/to/remote/repos > git fetch -f /path/to/remote/repos > > None of the above did the trick. The two remote commands reported that > everything was Already up-to-date! (even though I'd deleted a lot of local > working files)
Yes, there's really nothing to download. Everything that needs to be fetched has already been fetched :)
> What am I missing? How can I restore my previous state from last commit?
See `--hard` switch of `git reset`. Use with extreme caution.
To throw *everything* all your local work away and go back to the state of the remote repository, switch to `master` branch and do `git reset --hard origin/master` where `origin` is the name of your remote and `master` is the name of your remote branch.
To reset to the last commit without looking at the remote, run `git reset --hard`.
Note: Again, please understand what it's doing first; don't run it blindly.
-- Ram