Find which branch is used to create current branch in Git?

git

Solution

If all branches are created from master you could:

git merge-base master ${branch_in_question}

This only works if no merges have been done since branch creation. For the most part this is not a very easy question to answer in git. Unlike `svn log --stop-on-copy`. Not that I am saying I like subversion better.

Problem

I'm working on a project which is also worked on by a big team. As time passed by, people have been creating branches and pushing them to a remote repo. How do I know which branch was the root of a new branch created by another person? New branches can be created based off of current HEAD, but one could also specify `<start-point>` which can be a commit, a tag, or a branch. How do I find out which branch is used to create a new branch? A bonus question: commits could be pushed along with a branch creation. I'd like to log those commits pertaining to the new branch by using a post receive hook on the server. The hook is passed with (oldrev, newrev, refname), it would be nice if I can find out answer to my question above.

Original source

Related problems