Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git relative revision numbers

Tags:

git

Is it possible (somehow) to have in Git (local) relative revision (commit) numbers, like in Mercurial 0, 1, 2, 3, ... instead of short hashes?

Or anything more user friendly?

like image 901
Rook Avatar asked Feb 26 '11 18:02

Rook


People also ask

Does git have a revision number?

Other than that there are no revision numbers in git. You'll have to tag commits yourself if you want more user-friendliness.

What does Head@ 3 refer to?

}) ref~ is shorthand for ref~1 and means the commit's first parent. ref~2 means the commit's first parent's first parent. ref~3 means the commit's first parent's first parent's first parent.

What is Rev in git?

Git allows you to refer to a single commit, set of commits, or range of commits in a number of ways.


1 Answers

Just use:

  • master~10 to get the 10th last commit on branch master.
  • master^ to get the second last commit on branch master.
  • master^^ to get the third last commit on branch master.

They can even be combined: master^^~5^.

master can be any branch name (local or remote) or HEAD to reference the current commit.

You can use master^2 to get the second merge parent.

like image 60
knittl Avatar answered Sep 21 '22 14:09

knittl