Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git equivalent of "hg id"?

Tags:

Does Git have any command equivalent to Mercurial's "hg id"? I.e. a command that prints the parent commit's hash and a plus sign if there are changes in the working directory?

like image 278
Kostas Avatar asked Jan 15 '13 08:01

Kostas


People also ask

What is hg command?

Description. The hg command provides a command line interface to the Mercurial system.

What does hg commit do?

hg commit: save your changes in the current repository. hg log: see all changes in your repository. hg pull: get all changes from another repository into the current one. hg push: get all changes from your repository into another one.

What is hg init?

Hg Init: a Mercurial tutorial. Mercurial is a modern, open source, distributed version control system, and a compelling upgrade from older systems like Subversion. In this user-friendly, six-part tutorial, Joel Spolsky teaches you the key concepts.


2 Answers

This command is equivalent to hg id --id:

git describe --abbrev=12 --always --dirty=+

like image 170
smammy Avatar answered Oct 15 '22 15:10

smammy


git log -1 HEAD^

will show you the whole commit including the SHA-1

If it's a merge, you can see the second parent's commit info with

git log -1 HEAD^2

If you have an octopus merge with more than 2 parents you can put any number in the tree-ish spec:

git log -1 HEAD^5

... to see the 5th parent's commit info

the -1 just limits the log output to one commit. You don't want the lineage of that commit reported.

like image 40
Adam Dymitruk Avatar answered Oct 15 '22 14:10

Adam Dymitruk