git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* difference between "git reset --hard" and "git checkout -f"
@ 2008-04-30 11:37 Sitaram Chamarty
  2008-04-30 12:16 ` Miklos Vajna
  0 siblings, 1 reply; 3+ messages in thread
From: Sitaram Chamarty @ 2008-04-30 11:37 UTC (permalink / raw)
  To: git

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.

(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?

Thanks,

Sitaram

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: difference between "git reset --hard" and "git checkout -f"
  2008-04-30 11:37 difference between "git reset --hard" and "git checkout -f" Sitaram Chamarty
@ 2008-04-30 12:16 ` Miklos Vajna
  2008-04-30 12:47   ` Johannes Sixt
  0 siblings, 1 reply; 3+ messages in thread
From: Miklos Vajna @ 2008-04-30 12:16 UTC (permalink / raw)
  To: Sitaram Chamarty; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 948 bytes --]

On Wed, Apr 30, 2008 at 05:07:40PM +0530, Sitaram Chamarty <sitaramc@gmail.com> wrote:
> 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.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: difference between "git reset --hard" and "git checkout -f"
  2008-04-30 12:16 ` Miklos Vajna
@ 2008-04-30 12:47   ` Johannes Sixt
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Sixt @ 2008-04-30 12:47 UTC (permalink / raw)
  To: Sitaram Chamarty; +Cc: git

Miklos Vajna schrieb:
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-04-30 12:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-30 11:37 difference between "git reset --hard" and "git checkout -f" Sitaram Chamarty
2008-04-30 12:16 ` Miklos Vajna
2008-04-30 12:47   ` Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).