Information Technology Reference
In-Depth Information
How It Works
The command $ git checkout can be used to checkout just a single file without
switching branches. The syntax is following:
$ git checkout [REVISION] -- [filename]
You can pass an arbitrary revision identifier to it, of course. You can use HEAD , an-
cestor references, stash references, remote tracking branches, and reflog, to name a
few:
$ git checkout HEAD -- file.txt
$ git checkout stash@{3} -- file.txt
$ git checkout remotes/origin/master -- file.txt
$ git checkout HEAD@{yesterday} -- file.txt
The command allows you to use glob wildcards as well:
$ git checkout doc -- d*.txt
Two dashes separate a filename from commands options. Very often the dashes are
not crucial, as in $ git checkout doc d1.txt . They are necessary to disam-
biguate the options from paths. Here the -f acts as an option:
$ git checkout doc -f
And in the example below, the -f is interpreted as a path:
$ git checkout doc -- -f
Arbitrary versions of files stored in a database can also be displayed on your screen
without the need to check them out. This can be done with the $ git show com-
mand. You have to identify the revision and the file. This is done with the two paramet-
ers separated by a colon:
$ git show [REVISION]:[FILENAME]
Using this command you can check out a file and then save it under different name:
Search WWH ::




Custom Search