Search code examples
gitgit-log

How to get commit history for just one branch?


Let's say I created a new branch my_experiment from master and made several commits to my_experiment. If I do a git log when on my_experiment, I see the commits made to this branch, but also the commits made to master before the my_experiments branch was created.

I would find it very useful to see the history of all commits to the my_experiments branch until it hits the creation of that branch - effectively a true history of just that branch. Otherwise it's not clear to me when looking through the log whether the commits were on the my_experiments branch or not.

Is there a way to do this with Git?


Solution

  • You can use a range to do that.

    git log master..
    

    If you've checked out your my_experiment branch. This will compare where master is at to HEAD (the tip of my_experiment).