Git: how to see the work that was done on a branch that is now merged

We are going to switch from svn to git, and one of my users has a question. We have several long-lived branches. Periodically they are marked (rel_foo_10) and merged back with the master. We need to be able to list all the commits that were made to the release branches. Running git log master..rel_foo_10 (show all commits accessible from rel_foo_10 but not from the wizard) does not work, because after merging all the commits are reachable from the top of the wizard. Is this possible in git?

One idea would be to find the oldest branch point and make git log branchpoint..rel_foo_10. Is that easy? (git merge-base does not seem to do this, as it finds the last common ancestor, and I want the earliest).

Or what about git show-branch? It’s not clear to me from the man page how this command knows when to stop.

+4
source share
2 answers

The best solution that I have seen so far on the network is this one (in fact, it is modified from the ones that I found, use -date-order, which is necessary in order to correctly fix the border):

base=`git rev-list --boundary release_branch...master --date-order | \ grep '^-' | tail -1 | cut -c2-` git log $base..release_branch 

Is this the best / only way to get the (oldest) branch base in git?

+1
source

Last time I checked, this is not handled directly by git. I had the same need: I wanted my update on a live script site to send all the changes that were merged to all users. I did not find a tool that allows me to easily analyze the history of the repo to tell me when the branches started to differ. In other words, I could not programmatically find an early common ancestor.

These are the solutions I came up with: just create a branch from the master to the merge. This branch can be permanent if you like it or in my case it is temporary:

 git branch temp 

Now that you are merging, you have a link where the merge begins:

 git merge rel_foo_10 git log temp..HEAD 

Once I saved the log to a file, I can delete the temp branch. If you plan to create a permanent pre-merge branch, then perhaps you can name it using some convention, for example pre_rel_foo_10 .

0
source

All Articles