6

I'm pruning some branches off of a git remote.

How can I find out who created a branch on a remote git repository?

Maybe there is something similar to git branch -r --show-user?

David West
  • 2,256
  • 6
  • 32
  • 62

3 Answers3

6

The answer is pretty simple:

git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort

Taken from: Find out a Git branch creator

double-beep
  • 5,031
  • 17
  • 33
  • 41
Ilya Istomin
  • 92
  • 1
  • 2
2

See .git/logs/refs/heads/BRANCHNAME. The first line should contain information about the creation of the branch, including the user who created it and the commit from which the branch "forked".

git reflog can be used to examine the file programmatically; see git help reflog for details.

chepner
  • 497,756
  • 71
  • 530
  • 681
  • 4
    I don't think you're going to find anything here other than information on *local* branches. There won't be any information about branches created remotely. – larsks Feb 12 '14 at 21:22
1

I don't think there is a completely general answer to this in all cases. Consider:

A----B----C
      \
       D----E----F
             \
              G----H----I

Where was the branch containing commit I created? Was it a branch created from E, or from B. Both are possibilities - in one case, you have a branch created at D from B, then another branch created at G from E, in the other, you have D created from B, and then F created from E - in other words, the same tree could be represented like this:

A----B----C
      \
       D----E----G----H----I
             \
              F

Or even this:

A----B----D----E----G----H----I
      \         \
       C         F

All three of the above are topologically equivalent, and all three would give different answers to "where did branch I start?"...

twalberg
  • 59,951
  • 11
  • 89
  • 84
  • 1
    Branch `I` started with the commit from which it first branched. It's not apparent from the dag alone, but the information is retained by `git`. – chepner Feb 12 '14 at 19:33
  • @chepner True, if all branches were created locally. However, if `userA@repoA` creates the branch, pushes it to `origin`, and then `userB@repoB` fetches and tracks that branch, and adds more to it, that information is likely not available to `userB@repoB` without considerable forensic effort... In the general case, all you have is the DAG. Date stamps, etc. may add some additional information, but it's not a simple one-liner in general... – twalberg Feb 12 '14 at 19:51