Changes I made on the master branch of my fork got merged into master of the original project ("merged commit 95dd82b into tailwindlabs:master"). I want to make another contribution to this open source project. In the GitHub UI I pressed the "Fetch and merge" button. GitHub UI is still showing the message: "This branch is 4 commits ahead of tailwindlabs:master". Won't this confuse things if I try to make another contribution from this fork? How do I get parity with tailwindlabs:master?
CodePudding user response:
As you can see, back on Dec 10, you added a commit (5d15) directly to your own master
. You then made a further commit on Dec 13 (d309). Those are the two commits that you pushed up into your pull request.
Now let's look at your pull request:
We notice, however, two things:
First, this isn't your commit! Even though it has the same message as your first commit, it is a different commit; it is 95dd, whereas your commit with the same message (after the force push) was 5d15, and your second commit was d309.
Second, this isn't a merge! Notice that it has only one parent (the Update Changelog).
So your commit was not merged into tailwind's master
. It was copied onto tailwind's master
. It was cherry-picked, not merged at all. Probably tailwind is doing a so-called squash-and-merge here. This is a viable policy for dealing with PRs from a forked version of one's repo, but, despite its name, it is not a merge, and therefore it conceals the history — so that once again the tailwind people failed to notice that your branch is called master
.
The result is that your master
and its topology are completely unaffected by this event. Your branch was never merged into tailwind's master
. In fact, nothing in the history connects your commits (5d15 and d309) with tailwind's master
.
Okay, so at least we are ready to answer the question you originally asked. You are mystified by the status message
This branch is 4 commits ahead of tailwindlabs:master
But this is no mystery at all, because we can see what those 4 commits are! They are all the commits you have ever made on your master
:
Those are your commits, and (wait for it...) there are four of them! Meanwhile you seem to think that some kind of synchronization should be taking place here, but of course it isn't, because your master
is not tailwind's master
.
What to do? Well, you should never have made changes directly on master
to begin with, and the fact that the tailwind people failed to notice that you were making this mistake should have been another red flag for them:
But that's all water over the dam now. You must simply correct the situation at your end. The simplest way would be to delete your (evil) master
entirely. But perhaps you would like to preserve your branch for historical purposes. Then just "park" the last "good" commit on that branch by giving it a branch name:
git switch -c my-accidental-evil-branch d3095c19
Fine. Now get rid of your evil local master
:
git branch -D master
Now, if you'd like to start working another feature, do this:
Go to your repo at GitHub and update it from the upstream.
Return to your local repo and update it:
git fetch origin
Now make your feature branch!
git switch -c my-cool-feature origin/master
Now go forth and sin no more.