Resetting working files
Hi,
How do I reset the working files back to HEAD ?
Many thanks,
Aaron
Am 31.05.2009 15:09 schrieb Aaron Gray:
Quoted 8 lines
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
Quoted 9 lines · Dirk Süsserott
Am 31.05.2009 15:09 schrieb Aaron Gray:
Quoted 8 lines
Hi,
How do I reset the working files back to HEAD ?
Many thanks,
Aaron
[...]
Quoted 4 lines
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
A message that is not in the archive (sent off-list or not yet received): [email protected]
2009/5/31 bill lam <[email protected]>
Quoted 12 lines · Peter Baumann
Quoted 10 lines
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
Quoted 8 lines
Quoted 2 lines
(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
Quoted 7 lines · Aaron Gray
Quoted 5 lines
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'.
Signature · 1 line
Nicolas Sebrecht
Quoted 15 lines
Quoted 7 lines · Aaron Gray
Quoted 5 lines
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 $
Quoted 6 lines
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
2009/5/31 Nicolas Sebrecht <[email protected]>:
Quoted 5 lines
Quoted 2 lines · Aaron Gray
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.
Quoted 7 lines
Am 31.05.2009 15:09 schrieb Aaron Gray:
Quoted 6 lines
Hi,
How do I reset the working files back to HEAD ?
Many thanks,
Quoted 8 lines
Quoted 2 lines
Aaron
$ git reset --hardThis 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