# Resetting working files

8 messages from 2009-05-31 to 2009-05-31. Participants: Aaron Gray, Dirk Süsserott, Peter Baumann, Nicolas Sebrecht, Alex Riesen.
Thread: https://gitlist.dev/t/19616

## Aaron Gray, 2009-05-31 13:09

Subject: Resetting working files
Message-ID: <DA26600008CE404B831978F6EBB31C6B@HPLAPTOP>
URL: https://gitlist.dev/e/DA26600008CE404B831978F6EBB31C6B%40HPLAPTOP

```
Hi,

How do I reset the working files back to HEAD ?

Many thanks,

Aaron

```

## Dirk Süsserott, 2009-05-31 15:00

Subject: Re: Resetting working files
Message-ID: <4A229B9A.6060807@dirk.my1.cc>
URL: https://gitlist.dev/e/4A229B9A.6060807%40dirk.my1.cc
In-Reply-To: <DA26600008CE404B831978F6EBB31C6B@HPLAPTOP>

```
Am 31.05.2009 15:09 schrieb Aaron Gray:
> Hi,
> 
> How do I reset the working files back to HEAD ?
> 
> Many thanks,
> 
> Aaron
> 

$ git reset --hard

This will revert all changes you made in your working tree back to the 
HEAD. It will delete your changes made so far. To revert only a single 
file, use

$ git checkout -- path/to/file

```

## Aaron Gray, 2009-05-31 15:57

Subject: Re: Resetting working files
Message-ID: <D457E686769D44D8BE5DDC26FEEA4AE3@HPLAPTOP>
URL: https://gitlist.dev/e/D457E686769D44D8BE5DDC26FEEA4AE3%40HPLAPTOP
In-Reply-To: <4A229B9A.6060807@dirk.my1.cc>

```
> Am 31.05.2009 15:09 schrieb Aaron Gray:
>> Hi,
>> 
>> How do I reset the working files back to HEAD ?
>> 
>> Many thanks,
>> 
>> Aaron
>> 
> 
> $ git reset --hard
> 
> This will revert all changes you made in your working tree back to the 
> HEAD. It will delete your changes made so far. To revert only a single 
> file, use
> 
> $ git checkout -- path/to/file

Great thanks alot Dirk, you anticipated my second question too :)

Cheers,

Aaron

```

## Peter Baumann, 2009-05-31 16:25

Subject: Re: Resetting working files
Message-ID: <20090531162515.GB8129@m62s10.vlinux.de>
URL: https://gitlist.dev/e/20090531162515.GB8129%40m62s10.vlinux.de
In-Reply-To: <4A229B9A.6060807@dirk.my1.cc>

```
On Sun, May 31, 2009 at 05:00:42PM +0200, Dirk Süsserott wrote:
> Am 31.05.2009 15:09 schrieb Aaron Gray:
>> Hi,
>>
>> How do I reset the working files back to HEAD ?
>>
>> Many thanks,
>>
>> Aaron
>>

[...]

> To revert only a single file, use
>
> $ git checkout -- path/to/file
>

This will only reset the file content to the version in the index.
E.g. 

	echo modified >> a.txt
	git add a.txt
	git checkout -- a.txt           (1)

	git checkout HEAD -- a.txt	(2)


(1) This will do nothing to your file 'a.txt' in your workdir because
    the index and the workdir are identical

(2) This will reset your file to the state before you run that bogus
    echo modified >> a.txt   comand

Greetings,
Peter

```

## Aaron Gray, 2009-05-31 16:50

Subject: Re: Resetting working files
Message-ID: <9719867c0905310950x153db8efw179a8a10ac3f4640@mail.gmail.com>
URL: https://gitlist.dev/e/9719867c0905310950x153db8efw179a8a10ac3f4640%40mail.gmail.com
In-Reply-To: <20090531163225.GE3674@debian.b2j>

```
2009/5/31 bill lam <cbill.lam@gmail.com>
>
> On Sun, 31 May 2009, Peter Baumann wrote:
> >       echo modified >> a.txt
> >       git add a.txt
> >       git checkout -- a.txt           (1)
> >
> >       git checkout HEAD -- a.txt      (2)
> >
> >
> > (1) This will do nothing to your file 'a.txt' in your workdir because
> >     the index and the workdir are identical
> >
> > (2) This will reset your file to the state before you run that bogus
> >     echo modified >> a.txt   comand
>
> I still do not understand what index is.
> 1. is index an replica of the committed tree
> 2. is index only transient in that its content will be reset once
>   committed?
> 3. or other ?

I think index is HEAD or a revision hash. Am I correct ?

Aaron

```

## Nicolas Sebrecht, 2009-05-31 17:39

Subject: Re: Resetting working files
Message-ID: <20090531173932.GA13856@vidovic>
URL: https://gitlist.dev/e/20090531173932.GA13856%40vidovic
In-Reply-To: <9719867c0905310950x153db8efw179a8a10ac3f4640@mail.gmail.com>

```
The 31/05/09, Aaron Gray wrote:

> > I still do not understand what index is.
> > 1. is index an replica of the committed tree
> > 2. is index only transient in that its content will be reset once
> >   committed?
> > 3. or other ?
> 
> I think index is HEAD or a revision hash. Am I correct ?

HEAD is a reference to a branch name:
$ cat .git/HEAD
ref: refs/heads/master
$

The branch name is a reference to a commit:
$ cat .git/refs/heads/master
a80aad7b85fc560451e07792d64ab6cb15a39914
$

The index is what will be committed by 'git commit'.

-- 
Nicolas Sebrecht

```

## Aaron Gray, 2009-05-31 19:31

Subject: Re: Resetting working files
Message-ID: <34D6982455BA4A7E9F5D2D467DC4A55C@HPLAPTOP>
URL: https://gitlist.dev/e/34D6982455BA4A7E9F5D2D467DC4A55C%40HPLAPTOP
In-Reply-To: <20090531173932.GA13856@vidovic>

```
> The 31/05/09, Aaron Gray wrote:
>
>> > I still do not understand what index is.
>> > 1. is index an replica of the committed tree
>> > 2. is index only transient in that its content will be reset once
>> > committed?
>> > 3. or other ?
>>
>> I think index is HEAD or a revision hash. Am I correct ?
>
> HEAD is a reference to a branch name:
> $ cat .git/HEAD
> ref: refs/heads/master
> $
>
> The branch name is a reference to a commit:
> $ cat .git/refs/heads/master
> a80aad7b85fc560451e07792d64ab6cb15a39914
> $
>
> The index is what will be committed by 'git commit'.

Obviously alot more to learn about GIT, hopefully the O'Reilly book will 
clue me up as I am still getting problems with using GIT properly.

Thanks Nicolas,

Aaron

```

## Alex Riesen, 2009-05-31 21:30

Subject: Re: Resetting working files
Message-ID: <81b0412b0905311430v7874013cm6db84bd12d749134@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0905311430v7874013cm6db84bd12d749134%40mail.gmail.com
In-Reply-To: <20090531173932.GA13856@vidovic>

```
2009/5/31 Nicolas Sebrecht <nicolas.s.dev@gmx.fr>:
> The 31/05/09, Aaron Gray wrote:
>>
>> I think index is HEAD or a revision hash. Am I correct ?
>
> HEAD is a reference to a branch name:

Not really. Try "git checkout HEAD^" and run cat .git/HEAD

It is more a pointer to a commit. The pointers to a commit
in git are allowed to be indirect by referencing other pointers.

```
