I've two branches, master and live. Master is the development branch and contains commits that aren't ready to go into live.
What I want to be able to do is view all the commits that are in master than aren't in live, I've had a good search on here and Google and I was using this:
git log --cherry-pick --no-merges --oneline master...live
This worked until I merged live into master. But now it lists several commits that are in both.
So what is the correct command to view all commits that are in the master branch and not in the live branch?
On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.
Compare commits between two branches In some cases, you may be interested in knowing the commit differences between two branches. In order to see the commit differences between two branches, use the “git log” command and specify the branches that you want to compare.
To confirm, you can run git branch . The branch that you are on will be the one with a * next to it. Git checkout might fail with an error message, e.g. if it would overwrite modified files. Git branch should show you the current branch and git log master allows you to view commit logs without changing the branch.
You are very close. The correct command is:
git log --cherry-pick --oneline --no-merges --left-only master...live
from the log manpage:
--left-only, --right-only
List only commits on the respective side of a symmetric range, i.e. only those which would be marked < resp. > by --left-right.
For example, --cherry-pick --right-only A...B omits those commits from B which are in A or are patch-equivalent to a commit in A. In other words, this lists the + commits from git cherry A B. More precisely, --cherry-pick --right-only --no-merges gives the exact list.
git log master ^live --no-merges
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