reixiq
Last Updated: February 25, 2016
·
1.116K
· compnerd
537cdf5303cfb8f536e251c89042cbfd

Branch History with Branch Exclusions

When changes from multiple branches are needed in order to test integration with other parallel development, it can become difficult to view the history of the particular branch being worked on. I will be referring to three branches master, feature, and integration, the count and naming of which are for the sake of simplicity.

Because you need to get the changes from both master and feature into your branch. To do so, you happen to do this:

git checkout integration
git merge origin/master
git merge origin/feature

Now, if you do:

git log origin/master..

You will find that you have the history of changes on both the integration branch and feature branch intertwined. Often times, this will be what you want to see (since if you were to merge this branch into any other branch, these would be the set of commits which would be merged).

However, it can be useful to see what changes have been made just on the integration branch.

In order to do this, you can use a feature of git log to exclude commits from other branches.

git log --no-merges --oneline ^origin/feature origin/master..HEAD

Note that it is possible to expand this to an arbitrary number of branches by simply negating the branches which have been merged in.

Say Thanks
Respond