Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github - no file changes but many commits when comparing branches

Tags:

git

github

I'm comparing dev branch in my fork with the dev branch in the upstream. It shows diff of 30 commits, but 0 files changes. All the commits appear in the diff are old commits which already merged to the upstream (mainly type of "Merge branch dev.."). This makes an issue where each PR shows those many old commits. Tried rebase and still showing the same diff.

Why this happens? Can you please assist how to resolve? We're using Github for Enterprise so can't attach a url that show the diffs.

like image 233
Seffy Avatar asked Sep 14 '25 16:09

Seffy


1 Answers

Why this happens?

Possibly because you might have done PR (Pull Requests) from yourFork(origin)/dev and upstream/dev, which is not a good practice.
You would normally do a PR from a dedicated branch (myfix) to upstream/dev. And then simply reset your own dev to upstream/dev, in order to have in your fork an exact image of upstream/dev, and:

  • make new fix/feature branches for future PRs,
  • rebase existing fix/feature branches on top of dev in order to facilitate future PRs.

If everything is committed or stashed locally, I would:

  • create a dedicate branch (myfix or myfeature) right where my local dev is (assuming I was developing the next PR directly on dev)
  • reset dev to upstream dev

That is:

git switch dev
git branch myfix
git fetch upstream
git reset --hard upstream/dev
git push --force
git switch myfix
# resume working
like image 161
VonC Avatar answered Sep 17 '25 08:09

VonC