0

Suppose we are at a master branch with 2 commits: c111 and c222; c222 is the latest commit. Now, we create a new second branch by git checkout -b second; then keep working on second.

How do we find out that second was actually branched from master at c222? I understand that second will inherit both commits (c111 and c222 from master).

moey
  • 9,619
  • 20
  • 64
  • 109
  • 1
    possible duplicate of [Find the parent branch of a branch](http://stackoverflow.com/questions/3161204/find-the-parent-branch-of-a-branch) – Stefan Aug 05 '13 at 10:11
  • See also [Find which branch is used to create current branch in Git?](http://stackoverflow.com/questions/17665780/find-which-branch-is-used-to-create-current-branch-in-git) and [Branch length: where does a branch start in Git?](http://stackoverflow.com/questions/17581026/branch-length-where-does-a-branch-start-in-git). –  Aug 05 '13 at 14:31
  • See also [Finding a branch point with Git?](http://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git). –  Aug 05 '13 at 15:07

3 Answers3

2

Trygit log --all --graph --oneline --decorate, which prints out the git log as graph, containing the branch inheriting information.

nicky_zs
  • 3,176
  • 1
  • 16
  • 25
0

You need to use git merge-base A B git merge-base

Also this answer might help a lot.

Community
  • 1
  • 1
Tala
  • 8,298
  • 4
  • 30
  • 35
0

I am sure there is a good way to do this from the git command line tool, but I like using tig

Edit: It is easier to remember than git log --all --graph --oneline --decorate and also prettier! But yeah, you do have to install one additional tool.

Munim
  • 5,748
  • 2
  • 30
  • 41