I have a git remote "mine" (happens to be a github fork) that has managed to get ahead by 2 commits. My local master branch is ahead of it by 244 commits (pulled from the original gitub repo). As a result, pushing to "mine" is not fast-forward.
How can I list the 2 commits by which "mine" is ahead?
Your question is a little unclear, but it sounds like you want to list the commits on the remote branch that don't exist in your local branch yet. This is simply accomplished using a commit range ..
:
# Get the most recent updates from the remote
git fetch <remote>
# List all commits that are in <remote>/<branch> but not in your local <branch>
git log --oneline <branch>..<remote>/<branch>
From the official Linux Kernel git log
documentation:
<since>..<until>
Show only commits between the named two commits. When either
<since>
or<until>
is omitted, it defaults to HEAD, i.e. the tip of the current branch. For a more complete list of ways to spell<since>
and<until>
, see gitrevisions(7).