I’m having a couple of branches, corresponding with abandoned or later postponed development, some of them are pure garbage. I use
git log master..mybranch
to find out what’s mybranch all about, but the lists are usually needlessly long, since they contain also commits contained in master, just in a different order. This comes from master having been rebased.
When I try to rebase mybranch on top of master, I get conflicts caused by this reordering. Such conflicts are not worth resolving, as it takes time and leads to a result already known from master.
So what I need is a way to get rid of such commits in mybranch, so that only the important commits remains and the branch can be rebased more easily.
I think what you are looking for is
git cherry. This generates sha1 values from the commit body rather than using the git commit id to compare commits. This makes it independent of the commit ordering. You use it to find commits which might be worth adding from one branch to another.An example from the msysGit development tree might help. We have an old branch ‘work/symlink’ which may have been merged to the ‘devel’ branch sometime past. So:
This says there are 5 commits of interest (which we can also work out from the log output):
Thats the commits present on ‘work/symlink’ and not on ‘devel’. The git cherry output suggests that the aebecb0 commit is already applied to ‘devel’ (from the leading minus) but the others might be worth looking into. We can check that this commit is only present on the work branch:
but we can also find the commit id it got merged into the devel branch with by searching for the commit message using
git log --crepto see that this one was really picked into devel.