|
Re: With command-line jgit, how to checkout a single file back to its git version? [message #1767254 is a reply to message #1767187] |
Tue, 04 July 2017 08:36 |
Christian Halstrick Messages: 274 Registered: July 2009 |
Senior Member |
|
|
You have to be more precise and tell to what content you want to go back: the one of the last commit or the one which you added to the index. Often they are the same but not always (see the example below). To go back to the previously added content say 'jgit checkout -- <fileName>'. To go back to the content of the last commit (HEAD) you should do 'jgit checkout HEAD -- <fileName>'. I tried it out:
> jgit init
Initialized empty Git repository in /private/tmp/z/.git
> echo HeadContent >a
> jgit add a
> jgit commit -m initial
[master d891314c0a66142827058f9c33e329ee56396847] initial
> echo IndexContent >a
> jgit add a
> echo FileContent >a
> cat a
FileContent
> jgit checkout -- a
> cat a
IndexContent
> jgit checkout HEAD -- a
> cat a
HeadContent
Ciao
Chris
|
|
|
Powered by
FUDForum. Page generated in 0.24992 seconds