Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the git equivalent of hg heads / hg parents?

Tags:

git

In hg I can use hg heads to view all current heads. I still have not been able to find an equivalent in git. The git-hg rosetta stone doesn't give an answer.

As for hg parents which in hg simply tells the direct ancestors of a node the rosetta stone simply reads the very unhelpful:

git log # you can read all the information you need from there (as long as you already know the answer to the question you're asking) 
like image 641
George Mauer Avatar asked Feb 27 '12 22:02

George Mauer


2 Answers

git rev-list HEAD, git rev-list <sha1> and git rev-list HEAD -1 -- file are the equivalents of the different forms of hg parents

As for your detached HEAD problem, doing git checkout <sha1> is meant for commit inspection and not for general workflow. If you want a branch off a commit, you have to do git branch <name> <sha1> or git checkout -b <name> <sha1> and work on it.

Due to the above reason, I feel that it is not ideal to talk of the equivalent to hg heads in git as being all commits that don't have a child, but the closes equivalent is git branch

like image 51
manojlds Avatar answered Oct 18 '22 03:10

manojlds


You can view all named heads with git branch for branches and git tag for tags. I'm sure there's a fancy way to display all heads (i.e. dangling commits) but keep in mind that these may be garbage collected by git under the default settings.

UPDATE

I just realized that this is really unrelated to the concept of heads in Mercurial. This will really show you any named revisions in the repository, which may or may not be useful for your purposes.

like image 37
Michael Mior Avatar answered Oct 18 '22 02:10

Michael Mior