I am currently checking out other commits by using a commit's full hash id:
git checkout b56da2b535106d6df6d7caebfd455dd65b70eaf6
but this is a bit boring. Isn't there another way to do it? Maybe only typing the first letters of the hash or 开发者_JAVA技巧something? I have the idea of having read something alone those lines but I am not too sure about it.
Thanks
Ed
Yes, you can use any unambiguous prefix of the hash. Also, if you are trying to go through the history by a certain scheme, things like HEAD^^^
(i.e. the great grandparent of the current HEAD) work. See git help revisions
for more ways to specify this.
But I usually simply use copy+paste from gitk.
This is what I normally do when I need to get the full sha1 of anything on the commandline:
Copy the sha1 to the clipboard by double clicking it in xterm or gnome-terminal.
Get the sha1 to be pasted on the command line either by middle-clicking on the terminal window, or through a program, like so:
$ git checkout `p`
Where "p" is a shell script I have:
$ cat ~/bin/p
xcopy -r 2>/dev/null
You can get xcopy from Simon Tatham (of putty fame) here.
I used to use xclip to do the pasting, but I stopped using it for some reason I could not remember.
There are a bazillion different ways to specify commits listed in the "SPECIFYING REVISIONS" section of git-rev-parse, including some interesting ones like :/message
that uses the commit message.
精彩评论