Search code examples
gitbitbucket-cloud

Find branching history of current branch


There is a branch A that I am working on. I want to see the history of this branch. In the history I want to see things like master-> A3->A2->A1->A meaning that branch A3 was created from master and on top of A3, A2 was created.... So in history just the branch names.
How do I achieve this using git commands or bitbucket cloud?


Solution

  • Option 1:

    To see ONLY the relationship from one branch to another I recommend using the command:

    git log --merges --oneline master..A
    

    (assuming that the first branch is master and the last is A)

    Option 2:

    I like to use the git log command. This way, you get the list of branches under your current branch and also a graphical view of the history.

    I personally use this command:

    git log -n 50 --graph --pretty='%C(yellow)%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short
    

    But you can define various properties for this command if you want to customize it more. Just search a bit on git log.

    Specifically, if you want to control how many commits to show in your history then change the -n 50 to a different number.