I want to list all commits that are only part of a specific branch.
With the following, it lists all the commits from the branch, but also from the parent (master)
git log mybranch
The other option I found, was to exclude the commits reachable by master and gives me what I want, BUT I would like to avoid the need of knowing the other branches names.
git log mybranch --not master
I was trying to use git for-each-ref
, but it is also listing mybranch so actually it is excluding all:
git log mybranch --not $(git for-each-ref --format '^%(refname:short)' refs/heads/)
Update:
I'm testing a new option that I found a while ago, and till now seems that this could be what I was looking for:
git log --walk-reflogs mybranch
Update (2013-02-13T15:08):
The --walk-reflogs option is good, but I checked that there is an expiration for reflogs (default 90 days, gc.reflogExpire).
I think I found the answer I was looking for:
git log mybranch --not $(git for-each-ref --format='%(refname)' refs/heads/ | grep -v "refs/heads/mybranch")
I'm just removing the current branch from list of branches available and using that list to be excluded from the log. This way I only get the commits that are only reached by mybranch.
Git rev-list will list commits in one branch that are not in another branch. It is a great tool when you're trying to figure out if code has been merged into a branch or not. Using the --oneline option will display the title of each commit.
I think an option for your purposes is git log --oneline --decorate . This lets you know the checked commit, and the top commits for each branch that you have in your story line. By doing this, you have a nice view on the structure of your repo and the commits associated to a specific branch.
Graph all git branchesDevelopers can see all branches in the graph with the –all switch. Also, in most situations, the –decorate switch will provide all the supplemental information in a formatted and nicely color-coded way.
From what it sounds like you should be using cherry
:
git cherry -v develop mybranch
This would show all of the commits which are contained within mybranch, but NOT in develop. If you leave off the last option (mybranch), it will compare the current branch instead.
As VonC pointed out, you are ALWAYS comparing your branch to another branch, so know your branches and then choose which one to compare to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With