# Question about removing changes from the index

5 messages from 2009-02-06 to 2009-02-06. Participants: Gustav Hållberg, Björn Steinbrink, Sitaram Chamarty, Matthieu Moy.
Thread: https://gitlist.dev/t/17609

## Gustav Hållberg, 2009-02-06 13:57

Subject: Question about removing changes from the index
Message-ID: <a1e915350902060557m5a67eba0q819c2ba2a0a49c21@mail.gmail.com>
URL: https://gitlist.dev/e/a1e915350902060557m5a67eba0q819c2ba2a0a49c21%40mail.gmail.com

```
I'm wondering if there's anyone who can recommend a smart way to
"reset" the index entry for individual files to the contents of HEAD,
in effect, removing any previous change between HEAD and the index
(for those files).

I'm aware that 'git gui' lets you do this (in a human-friendly way)
but I want to do this from a script (and am not concerned about the
human-friendliness, as long as it's not too programmer-unfriendly).

Thanks,
Gustav

```

## Björn Steinbrink, 2009-02-06 14:09

Subject: Re: Question about removing changes from the index
Message-ID: <20090206140911.GC31491@atjola.homenet>
URL: https://gitlist.dev/e/20090206140911.GC31491%40atjola.homenet
In-Reply-To: <a1e915350902060557m5a67eba0q819c2ba2a0a49c21@mail.gmail.com>

```
On 2009.02.06 14:57:35 +0100, Gustav Hållberg wrote:
> I'm wondering if there's anyone who can recommend a smart way to
> "reset" the index entry for individual files to the contents of HEAD,
> in effect, removing any previous change between HEAD and the index
> (for those files).

Believe it or not, it's "git reset" ;-)

git reset -- file

You can only reset the index entry for that file to some older version,
e.g. "git reset HEAD~5 -- file".

Björn

```

## Matthieu Moy, 2009-02-06 14:11

Subject: Re: Question about removing changes from the index
Message-ID: <vpqprhvbqpk.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqprhvbqpk.fsf%40bauges.imag.fr
In-Reply-To: <a1e915350902060557m5a67eba0q819c2ba2a0a49c21@mail.gmail.com>

```
Gustav Hållberg <gustav@gmail.com> writes:

> I'm wondering if there's anyone who can recommend a smart way to
> "reset" the index entry for individual files to the contents of HEAD,
> in effect, removing any previous change between HEAD and the index
> (for those files).

Isn't "git reset -- path" what you want? Or perhaps "git checkout HEAD
-- path" if you also want to reset the file content.

-- 
Matthieu

```

## Sitaram Chamarty, 2009-02-06 14:14

Subject: Re: Question about removing changes from the index
Message-ID: <slrngoohdp.rak.sitaramc@sitaramc.homelinux.net>
URL: https://gitlist.dev/e/slrngoohdp.rak.sitaramc%40sitaramc.homelinux.net
In-Reply-To: <a1e915350902060557m5a67eba0q819c2ba2a0a49c21@mail.gmail.com>

```
On 2009-02-06, Gustav Hållberg <gustav@gmail.com> wrote:
> I'm wondering if there's anyone who can recommend a smart way to
> "reset" the index entry for individual files to the contents of HEAD,
> in effect, removing any previous change between HEAD and the index
> (for those files).

err.. 'git reset HEAD -- file'?  The man page says "The
second form with paths is used to revert selected paths in
the index from a given commit, without moving HEAD."

```

## Gustav Hållberg, 2009-02-06 14:51

Subject: Re: Question about removing changes from the index
Message-ID: <a1e915350902060651r142e8d87gd013376a866e5158@mail.gmail.com>
URL: https://gitlist.dev/e/a1e915350902060651r142e8d87gd013376a866e5158%40mail.gmail.com
In-Reply-To: <20090206140911.GC31491@atjola.homenet>

```
Thanks everyone; I feel appropriately silly now :-)

- Gustav

```
