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

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

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Apr 30, 2008, 12:47 UTC
Message-ID
<48186A77.9040601@viscovery.net>
In-Reply-To
<20080430121606.GA23672@genesis.frugalware.org>
Miklos Vajna schrieb:
Show 8 quoted lines
> On Wed, Apr 30, 2008 at 05:07:40PM +0530, Sitaram Chamarty <sitaramc@gmail.com> wrote:
>> (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.

Moreover, if you are in the middle of a merge (e.g. when there are merge conflicts, or after git merge --no-commit), git reset --hard forgets about the merge, but git checkout -f does not; hence, a git commit after the latter would create a merge commit, which is usually not what you want.

-- Hannes
Previous: Miklos Vajna
Message 3 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.