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

Re: difference between "git reset --hard" and "git checkout -f"

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Apr 30, 2008, 12:16 UTC
Message-ID
<20080430121606.GA23672@genesis.frugalware.org>
In-Reply-To
<2e24e5b90804300437t39ac16a6ga3cbe0b91d7e5565@mail.gmail.com>
On Wed, Apr 30, 2008 at 05:07:40PM +0530, Sitaram Chamarty <sitaramc@gmail.com> wrote:
Show 5 quoted lines
> I have two questions:
> 
> (1) as in the subject line, what's the difference between these two
> commands?  (I'm talking about those exact commands, not variations).
> I am unable to see any.

git checkout is the tool to check out a branch or paths. git reset is to reset HEAD (and as a side effect the working directory as well). so i think only the sematics differ, there is no difference in practice.

> (2) shouldn't one of these have an option to throw away untracked
> files also, to get to a pristine HEAD-eqvt state?  Or is it better to
> force user to use git clean separately for that?

i would say so. we already require (by default) to use git clean -f, as it may wipe out your work (in case you forgot to git add some important files), so just adding an other option to perform this dangerous operation would not be good imho.

Previous: Sitaram ChamartyNext: Johannes Sixt
Message 2 of 3 in “difference between "git reset --hard" and "git checkout -f"”
  1. Sitaram ChamartyApr 30, 2008
  2. Miklos VajnaApr 30, 2008
  3. Johannes SixtApr 30, 2008

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.