What does git rev-parse do?
I have read the man page but it raised more questions than answers. Things like:
Pick out and massage parameters
Massage? What does that mean?
I'm using as a resolver (to SHA1) of revision specifiers, like
git rev-parse HEAD^
or
git rev-parse origin/master
Is this the command’s purpose? If not, is even correct to use it to achieve this?
git rev-parseis an ancillaryplumbingcommand primarily used for manipulation.One common usage of
git rev-parseis to print the SHA1 hashes given a revision specifier. In addition, it has various options to format this output such as--shortfor printing a shorter unique SHA1.There are other use cases as well (in scripts and other tools built on top of git) that I've used for:
--verifyto verify that the specified object is a valid git object.--git-dirfor displaying the abs/relative path of the.gitdirectory.--is-inside-git-diror within a work-tree using--is-inside-work-tree--is-bare-repository--branches), tags (--tags) and the refs can also be filtered based on the remote (using--remote)--parse-optto normalize arguments in a script (kind of similar togetopt) and print an output string that can be used withevalMassagejust implies that it is possible to convert the info from one form into another i.e. a transformation command. These are some quick examples I can think of:A..Bforgit logorgit diffinto the equivalent arguments for the underlying plumbing command asB ^A