0

I have a GitHub repo forked from a public repo (also on GitHub). No matter what I do, I am always getting this message. No matter how how many fetches and pulls I do. Even after submitting changes in a PR (which were accepted) it still tells me I'm several commits ahead.

If I try to create a PR to see what changes there are, I'll be told something like: enter image description here

I even ran git reset --hard upstream/master but it didn't make any difference. GitHub website still says my fork is 7 commits ahead, and now the GitHub desktop app says:

enter image description here

It's just getting ridiculous. Fortunately I have no outstanding work so I can delete my fork, but if I had made changes I wouldn't be able to contribute them.

What more can I do?

Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
  • 1
    Does `git diff master origin/master` show anything (assuming your fork on github is origin)? – snakecharmerb Aug 08 '21 at 14:09
  • 3
    Have you run `git fetch upstream` recently? `master` may be up-to-date with your local copy of `upstream/master`, but not the *actual* upstream master. – chepner Aug 08 '21 at 14:09
  • @chepner I have deleted the fork but this sounds like it could be plausible. Maybe you could provide this as an answer and when I finish my current work and doubtless run into this again, I can confirm?! – Mr. Boy Aug 08 '21 at 14:12
  • 1
    Have you (force) pushed your master branch to your fork on GitHub (which I assume would be `origin`) after resetting it to `upstream/master`? – a544jh Aug 08 '21 at 17:49
  • [Hard resetting this way](https://stackoverflow.com/a/61490618/184546) will certainly solve your problem, but make sure that's actually what you want. – TTT Aug 08 '21 at 21:25

2 Answers2

1

git status is reporting differences between master and your local copy of upstream/master. If your local copy itself is behind the actual master branch, this is the type of warning you may receive.

chepner
  • 497,756
  • 71
  • 530
  • 681
0

You are getting the message because you made some changes in the master (local one) but didn't push them to the remote.

Using the below rules, it will be solved hopefully:

  1. If you want to push the local changes that you made, run the command git push origin.
  2. If you don't want to commit the local changes, hard reset them using git reset --hard origin/master.
Sonia Singla
  • 102
  • 6