I was about to push a revision and did my customary
git log origin/main...HEAD --oneline
Here is what it displayed:
48dfad4d2e7b (HEAD -> main, bang) [TableGen] Fix bug in !interleave operator
496fb70b141c (origin/main) [MachO] Fix enum-int mismatch warning
e73f885c988d (origin/master, origin/HEAD) [PowerPC] Remove redundant
COPY_TO_REGCLASS introduced by 8a58f21f5b6c
c3b9d85bd4b7 [clang-tidy][NFC] Remove unnecessary headers
What is going on with the third commit?
The ...
you’re using in git log
shows you the difference between your local branch and the remote. So all these commits are the ones that are in either but not both.
If you just want to see your local change not in the remote branch, you need to use online two dots: git log origin/main…HEAD --oneline
This last syntax is equivalent to git log ^origin/main HEAD --oneline
And HEAD is also implicit so you can write:
git log origin/main… --oneline
or: git log ^origin/main --oneline
Oh, sorry, my original message was wrong. The 'git log origin...' showed only the first commit, the one I wanted to push. It was a 'git log --oneline 10' that showed this:
48dfad4d2e7b (HEAD -> main, bang) [TableGen] Fix bug in !interleave operator
496fb70b141c (origin/main) [MachO] Fix enum-int mismatch warning
e73f885c988d (origin/master, origin/HEAD) [PowerPC] Remove redundant
COPY_TO_REGCLASS introduced by 8a58f21f5b6c
c3b9d85bd4b7 [clang-tidy][NFC] Remove unnecessary headers
...
What I don't understand is the "origin/master, origin/HEAD' part. What is going on there?
Oh, sorry, my original message was wrong. The ‘git log origin…’ showed only the first commit, the one I wanted to push. It was a ‘git log --oneline 10’ that showed this:
48dfad4d2e7b (HEAD → main, bang) [TableGen] Fix bug in !interleave operator
496fb70b141c (origin/main) [MachO] Fix enum-int mismatch warning
e73f885c988d (origin/master, origin/HEAD) [PowerPC] Remove redundant
COPY_TO_REGCLASS introduced by 8a58f21f5b6c
c3b9d85bd4b7 [clang-tidy][NFC] Remove unnecessary headers
…
What I don’t understand is the "origin/master, origin/HEAD’ part. What is going on there?
These in parenthesis are indicating the head of each branch, local or remote.
Yes, but why doesn't origin/HEAD point to the same commit as origin/main?
origin/HEAD is set locally to the default remote branch at the time you clone the repo. In a fresh clone it’ll point to origin/main.
You can change it with: git remote set-head origin main
This is querying the remote to get the current remote state, i.e. what is set when you clone. This does not show the local state, you can try: cat .git/refs/remotes/origin/HEAD
Then run git remote set-head origin main and check again.
You can also run git remote set-head origin -a instead, it’ll query the remote the same way as you see with git remote show origin and set it to main as well.
Aha. Now I understand. All set. I'm surprised I didn't notice this before.
Thanks for your help!