I trying to build a git log command to show commits reachable from commit1 but not reachable from a set of other commits (commit2 ...). However I seem to be doing something wrong with a command to exclude those reachable from just one (commit2) using the ^ prefix notation and I hope somebody can show me what I've got wrong.
I'm successfully using the ".." revision range syntax. It correctly returns 2 commits as shown below:
>git log 349ef28..4b58345 --pretty="format:%H"
4b58345764e1527ce150e1b31bb722130e018651
eaf22be216276964d5c07ca9196c6ab48041b046
But when I use the ^ prefix fails, it just lists everything. I expected both to return the same two commit SHAs.
>git log ^349ef28 4b58345 --pretty="format:%H"
4b58345764e1527ce150e1b31bb722130e018651
eaf22be216276964d5c07ca9196c6ab48041b046
349ef283776d6c5374894bcc571267a0bee24fd5
aeb1fd3b65fe9c82bad839bd9f34e0bc2603290d
aef60d126e5ea756ef44cccb43cda28044a560ed
:
I've tried:
What am I doing wrong?
Updated: Replaced image with text as requested.
You are using the Windows command line CMD. This beast treats ^
specially (it is some sort of escape character). You have to type it twice for every occurrence where you need one of them:
git log ^^1234abcd 5678ef01
However, the pager, less
, does its own terminal emulation, where this special treatment is not needed. For example, to search for the beginning of the next commit, i.e., the word commit
at the beginning of a line, type /^commitEnter. Note that we use just one ^. (Then to search for further commits, just type n.)