I ran into an interesting problem today that took a bit longer to figure out, and so I will post it here in the hopes that others will find the solution faster than I did.
My problem: I am inspecting a rather large and complex piece of software and need to look at its history – more specifically, I need to figure out when certain branches were created and who created them.
Now, I could have just hacked together a throw-away solution, but that’s not who I am. As I was looking, I found that there didn’t seem to be much on this – aside from the Stack Overflow questions.
So I whipped up a little script that gets all of the branches in the git repo and lists the details of their first commit. These details include the date, and creator – which is what I needed. (Bash script)
# # Author: Caleb Shortt # # For some reason, lists the files and directories' # history as well...(They're not all branches) # # Sources: # Stack Overflow: Question: "What is the easiest/fastest way to find out when # a git branch was created" # readarray -t branch_list <<< $(git branch -a) for branch in ${branch_list[@]} do echo '---------------------------------------------' echo "Branch: $branch" echo '---------------------------------------------' git show --summary `git merge-base master $branch` done
Now there is a little hiccup with the script also printing out the details of whatever is in the directory, but the details for the branches are in there. I’ll update this if I figure out why it’s doing that.