git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Resetting working files
@ 2009-05-31 13:09 Aaron Gray
  2009-05-31 15:00 ` Dirk Süsserott
  0 siblings, 1 reply; 8+ messages in thread
From: Aaron Gray @ 2009-05-31 13:09 UTC (permalink / raw)
  To: Git Mailing List

Hi,

How do I reset the working files back to HEAD ?

Many thanks,

Aaron

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

* Re: Resetting working files
  2009-05-31 13:09 Resetting working files Aaron Gray
@ 2009-05-31 15:00 ` Dirk Süsserott
  2009-05-31 15:57   ` Aaron Gray
  2009-05-31 16:25   ` Peter Baumann
  0 siblings, 2 replies; 8+ messages in thread
From: Dirk Süsserott @ 2009-05-31 15:00 UTC (permalink / raw)
  To: Aaron Gray; +Cc: Git Mailing List

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

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

* Re: Resetting working files
  2009-05-31 15:00 ` Dirk Süsserott
@ 2009-05-31 15:57   ` Aaron Gray
  2009-05-31 16:25   ` Peter Baumann
  1 sibling, 0 replies; 8+ messages in thread
From: Aaron Gray @ 2009-05-31 15:57 UTC (permalink / raw)
  To: Dirk Süsserott; +Cc: Git Mailing List

> 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

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

* Re: Resetting working files
  2009-05-31 15:00 ` Dirk Süsserott
  2009-05-31 15:57   ` Aaron Gray
@ 2009-05-31 16:25   ` Peter Baumann
       [not found]     ` <20090531163225.GE3674@debian.b2j>
  1 sibling, 1 reply; 8+ messages in thread
From: Peter Baumann @ 2009-05-31 16:25 UTC (permalink / raw)
  To: Dirk Süsserott; +Cc: Aaron Gray, Git Mailing List

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

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

* Re: Resetting working files
       [not found]     ` <20090531163225.GE3674@debian.b2j>
@ 2009-05-31 16:50       ` Aaron Gray
  2009-05-31 17:39         ` Nicolas Sebrecht
  0 siblings, 1 reply; 8+ messages in thread
From: Aaron Gray @ 2009-05-31 16:50 UTC (permalink / raw)
  To: Peter Baumann, Aaron Gray, Git Mailing List

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

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

* Re: Resetting working files
  2009-05-31 16:50       ` Aaron Gray
@ 2009-05-31 17:39         ` Nicolas Sebrecht
  2009-05-31 19:31           ` Aaron Gray
  2009-05-31 21:30           ` Alex Riesen
  0 siblings, 2 replies; 8+ messages in thread
From: Nicolas Sebrecht @ 2009-05-31 17:39 UTC (permalink / raw)
  To: Aaron Gray; +Cc: Peter Baumann, Git Mailing List

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

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

* Re: Resetting working files
  2009-05-31 17:39         ` Nicolas Sebrecht
@ 2009-05-31 19:31           ` Aaron Gray
  2009-05-31 21:30           ` Alex Riesen
  1 sibling, 0 replies; 8+ messages in thread
From: Aaron Gray @ 2009-05-31 19:31 UTC (permalink / raw)
  To: Nicolas Sebrecht; +Cc: Peter Baumann, Git Mailing List

> 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

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

* Re: Resetting working files
  2009-05-31 17:39         ` Nicolas Sebrecht
  2009-05-31 19:31           ` Aaron Gray
@ 2009-05-31 21:30           ` Alex Riesen
  1 sibling, 0 replies; 8+ messages in thread
From: Alex Riesen @ 2009-05-31 21:30 UTC (permalink / raw)
  To: Nicolas Sebrecht; +Cc: Aaron Gray, Peter Baumann, Git Mailing List

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.

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

end of thread, other threads:[~2009-05-31 21:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-31 13:09 Resetting working files Aaron Gray
2009-05-31 15:00 ` Dirk Süsserott
2009-05-31 15:57   ` Aaron Gray
2009-05-31 16:25   ` Peter Baumann
     [not found]     ` <20090531163225.GE3674@debian.b2j>
2009-05-31 16:50       ` Aaron Gray
2009-05-31 17:39         ` Nicolas Sebrecht
2009-05-31 19:31           ` Aaron Gray
2009-05-31 21:30           ` Alex Riesen

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).