Hatjhie
Hatjhie

Reputation: 1365

Get Branch Revision Number

I have branch A. Head Revision is 1. Then, I create branch B from branch A with head revision 1.

Afterwards, I am using branch B, until the head revision changed as below:

1
2
3
4
10 <- HEAD

Is there any Git Command I could run in branch B to get the revision number when the branch B first branch out? In this case, I want the command to return 1 as 1 is the head revision of branch A when branch B is created from branch A.

Thank you,

Hatjhie

Upvotes: 1

Views: 273

Answers (2)

sergej
sergej

Reputation: 18009

If you have something like this:

      5 - 6 - 7 (HEAD -> B)              
     /     
1 - 2 - 3 - 4 - 8 (A)
    ^
    |
   (fork point)

You can run

git merge-base --fork-point A

on B to see where A was forked from B.

git merge-base finds best common ancestor(s) between two commits ...

Upvotes: 1

Emmanuel Arias
Emmanuel Arias

Reputation: 484

I think if you use this command:

git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all

you will get the things you want.

source:

https://gist.github.com/eamanu/1c30435ff6e2f9ebb1ef8ef359c9d34c

Upvotes: 1

Related Questions