1 to 2 weeks ago, I found a reference on the web, saying that this command:
$ git diff origin <branch> HEAD
will show the present (local) commits that have not yet been pushed to remote. Since then, I have figured out that, as long as I am in the specified branch of interest, I do not need to specify the branch name on that command line.
I've been using that command, ever since, to help me perform some experiments, to help me learn how Git/GitLab work. Staying only in the development
branch and doing no merges, I have repeatedly been able to:
- use that command to display not-yet-pushed commits; and then, after doing the "push"
- to run that command again and notice that all the previous commits, in the output of that command, were completely gone - i.e., the command gave no output.
But now I am experiencing some inconsistencies in the output of that command:
- I created a new branch, off of
master
, calledjravery
. - I then created a new sub-branch, off of
jravery
, calledjrasub
. - I added some files to
jrasub
; then staged & committed & pushed them. - Then I merged
jrasub
intojravery
; then I did agit push
, in thejravery
branch.
But now I do the git diff origin {branch} HEAD
command and I still see those 2 files, whether the specified branch is jravery
or jrasub
.
Why were the committed-and-then-pushed files/commits disappearing from the output of that diff
command last week, after push, but now still appearing in the output of that same command this week (also after push)?
Also in the output of that command - whether I specify master
or jravery
or jrasub
as the branch - I am seeing a few other files that were never included in either the jravery
or the jrasub
branch. However, when I specify the development
branch, nothing shows up in the output of that command, even though most of the files that are otherwise showing up in this command's output are - or were - only in the development
branch (unless and until they might eventually have been merged into master
) and never were part of either jravery
or jrasub
.
Why is that?