# checkout vs reset

3 messages from 2009-02-26 to 2009-02-26. Participants: Jay Soffian, Sitaram Chamarty.
Thread: https://gitlist.dev/t/18028

## Jay Soffian, 2009-02-26 07:08

Subject: checkout vs reset
Message-ID: <76718490902252308r474b193yba21b14e14a3baa@mail.gmail.com>
URL: https://gitlist.dev/e/76718490902252308r474b193yba21b14e14a3baa%40mail.gmail.com

```
Is there any different between the following two commands?

git reset <commit> -- <paths>...
git checkout <commit> -- <paths>...

As far as I can tell from the man pages, they are equivalent. To wit:
both update the index and working copy for the given paths to the
state that they were in in <commit>.

j.

```

## Jay Soffian, 2009-02-26 07:12

Subject: Re: checkout vs reset
Message-ID: <76718490902252312h6a08f5a6x972523e7c7e4af16@mail.gmail.com>
URL: https://gitlist.dev/e/76718490902252312h6a08f5a6x972523e7c7e4af16%40mail.gmail.com
In-Reply-To: <76718490902252308r474b193yba21b14e14a3baa@mail.gmail.com>

```
On Thu, Feb 26, 2009 at 2:08 AM, Jay Soffian <jaysoffian@gmail.com> wrote:
> Is there any different between the following two commands?
>
> git reset <commit> -- <paths>...
> git checkout <commit> -- <paths>...
>
> As far as I can tell from the man pages, they are equivalent. To wit:
> both update the index and working copy for the given paths to the
> state that they were in in <commit>.

Doh, answering my own question. reset only touches the index, not the
working copy. checkout updates both.

j.

```

## Sitaram Chamarty, 2009-02-26 09:15

Subject: Re: checkout vs reset
Message-ID: <slrngqcnd8.t1u.sitaramc@sitaramc.homelinux.net>
URL: https://gitlist.dev/e/slrngqcnd8.t1u.sitaramc%40sitaramc.homelinux.net
In-Reply-To: <76718490902252312h6a08f5a6x972523e7c7e4af16@mail.gmail.com>

```
On 2009-02-26, Jay Soffian <jaysoffian@gmail.com> wrote:
> On Thu, Feb 26, 2009 at 2:08 AM, Jay Soffian <jaysoffian@gmail.com> wrote:
>> Is there any different between the following two commands?
>>
>> git reset <commit> -- <paths>...
>> git checkout <commit> -- <paths>...
>>
>> As far as I can tell from the man pages, they are equivalent. To wit:
>> both update the index and working copy for the given paths to the
>> state that they were in in <commit>.
>
> Doh, answering my own question. reset only touches the index, not the
> working copy. checkout updates both.

However, if the <commit> doesn't even _have_ the <path> in
question, it leaves the index alone (doesn't remove it, for
instance):

Using HEAD as the <commit> in question for this example:

    echo hi > abc       # new file, untracked so far
    git add abc
    git status          # it's staged
    git reset HEAD -- abc
    git status          # untracked

    # now with checkout
    git add abc
    git status          # staged
    git checkout HEAD -- abc
    git status          # still staged

```
