{"thread":{"id":"13333","subject":"difference between \"git reset --hard\" and \"git checkout -f\"","startedAt":"2008-04-30T11:37:40Z","lastAt":"2008-04-30T12:47:51Z","messageCount":3,"participants":["Sitaram Chamarty","Miklos Vajna","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"75670","messageId":"2e24e5b90804300437t39ac16a6ga3cbe0b91d7e5565@mail.gmail.com","threadId":"13333","inReplyTo":null,"subject":"difference between \"git reset --hard\" and \"git checkout -f\"","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2008-04-30T11:37:40Z","receivedAt":"2008-04-30T11:37:40Z","isPatch":false,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"I have two questions:\n\n(1) as in the subject line, what's the difference between these two\ncommands?  (I'm talking about those exact commands, not variations).\nI am unable to see any.\n\n(2) shouldn't one of these have an option to throw away untracked\nfiles also, to get to a pristine HEAD-eqvt state?  Or is it better to\nforce user to use git clean separately for that?\n\nThanks,\n\nSitaram\n"},{"id":"75676","messageId":"20080430121606.GA23672@genesis.frugalware.org","threadId":"13333","inReplyTo":"2e24e5b90804300437t39ac16a6ga3cbe0b91d7e5565@mail.gmail.com","subject":"Re: difference between \"git reset --hard\" and \"git checkout -f\"","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-04-30T12:16:06Z","receivedAt":"2008-04-30T12:16:06Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Apr 30, 2008 at 05:07:40PM +0530, Sitaram Chamarty <sitaramc@gmail.com> wrote:\n> I have two questions:\n> \n> (1) as in the subject line, what's the difference between these two\n> commands?  (I'm talking about those exact commands, not variations).\n> I am unable to see any.\n\ngit checkout is the tool to check out a branch or paths. git reset is to\nreset HEAD (and as a side effect the working directory as well). so i\nthink only the sematics differ, there is no difference in practice.\n\n> (2) shouldn't one of these have an option to throw away untracked\n> files also, to get to a pristine HEAD-eqvt state?  Or is it better to\n> force user to use git clean separately for that?\n\ni would say so. we already require (by default) to use git clean -f, as\nit may wipe out your work (in case you forgot to git add some important\nfiles), so just adding an other option to perform this dangerous\noperation would not be good imho.\n"},{"id":"75677","messageId":"48186A77.9040601@viscovery.net","threadId":"13333","inReplyTo":"20080430121606.GA23672@genesis.frugalware.org","subject":"Re: difference between \"git reset --hard\" and \"git checkout -f\"","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-04-30T12:47:51Z","receivedAt":"2008-04-30T12:47:51Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Miklos Vajna schrieb:\n> On Wed, Apr 30, 2008 at 05:07:40PM +0530, Sitaram Chamarty <sitaramc@gmail.com> wrote:\n>> (1) as in the subject line, what's the difference between these two\n>> commands?  (I'm talking about those exact commands, not variations).\n>> I am unable to see any.\n> \n> git checkout is the tool to check out a branch or paths. git reset is to\n> reset HEAD (and as a side effect the working directory as well). so i\n> think only the sematics differ, there is no difference in practice.\n\nMoreover, if you are in the middle of a merge (e.g. when there are merge\nconflicts, or after git merge --no-commit), git reset --hard forgets about\nthe merge, but git checkout -f does not; hence, a git commit after the\nlatter would create a merge commit, which is usually not what you want.\n\n-- Hannes\n"}]}