git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: gzollerNext: Jan Hudec
Message 2 of 6 in “Newbie: Restore messed up code from local or remote repository”
  1. gzollerNov 12, 2010
  2. Ramkumar RamachandraNov 12, 2010
  3. Jan HudecNov 12, 2010
  4. Santi BéjarNov 12, 2010
  5. gzollerNov 12, 2010
  6. Matthieu MoyNov 12, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.