This does not seem to be an issue with git
but with whatever source code management tool you are using, that created the PR. Here's a simple test:
My original branch (with --format=fuller
):
commit 18cabfe932ad37e210bebf14c3c5084f65629962 (HEAD -> master)
Author: Sam Varshavchik <mrsam@courier-mta.com>
AuthorDate: Thu Jul 14 20:09:48 2022 -0400
Commit: Sam Varshavchik <mrsam@courier-mta.com>
CommitDate: Thu Jul 14 20:09:48 2022 -0400
Commit 3
commit 4a12c468a08fcb17945ca08aa2032594f6988724
Author: Sam Varshavchik <mrsam@courier-mta.com>
AuthorDate: Thu Jul 14 20:09:24 2022 -0400
Commit: Sam Varshavchik <mrsam@courier-mta.com>
CommitDate: Thu Jul 14 20:09:24 2022 -0400
Commit 2
commit ff0b2a68da3c22179279ef2b009616f659f4ffd1
Author: Sam Varshavchik <mrsam@courier-mta.com>
AuthorDate: Thu Jul 14 20:09:02 2022 -0400
Commit: Sam Varshavchik <mrsam@courier-mta.com>
CommitDate: Thu Jul 14 20:09:02 2022 -0400
Commit 1
commit 5f9cf33419421f45313ccec60dad105337de4d6f
Author: Sam Varshavchik <mrsam@courier-mta.com>
AuthorDate: Thu Jul 14 20:08:31 2022 -0400
Commit: Sam Varshavchik <mrsam@courier-mta.com>
CommitDate: Thu Jul 14 20:08:31 2022 -0400
Initial commit
After performing the rebase, and squashing only the last two commits:
$ history
...
1003 git rebase -i HEAD~3
1004 git log --format=fuller
1005 history
The end result:
commit 544d3deeeea682b195f64421b8ef33b2e91043da (HEAD -> master)
Author: Sam Varshavchik <mrsam@courier-mta.com>
AuthorDate: Thu Jul 14 20:09:24 2022 -0400
Commit: Sam Varshavchik <mrsam@courier-mta.com>
CommitDate: Thu Jul 14 20:10:26 2022 -0400
Commit 2
Commit 3
commit ff0b2a68da3c22179279ef2b009616f659f4ffd1
Author: Sam Varshavchik <mrsam@courier-mta.com>
AuthorDate: Thu Jul 14 20:09:02 2022 -0400
Commit: Sam Varshavchik <mrsam@courier-mta.com>
CommitDate: Thu Jul 14 20:09:02 2022 -0400
Commit 1
commit 5f9cf33419421f45313ccec60dad105337de4d6f
Author: Sam Varshavchik <mrsam@courier-mta.com>
AuthorDate: Thu Jul 14 20:08:31 2022 -0400
Commit: Sam Varshavchik <mrsam@courier-mta.com>
CommitDate: Thu Jul 14 20:08:31 2022 -0400
Initial commit
As can be seen here "Commit 1", the third oldest commit, is completely unchanged and still carries the same commit hash.
git rebase
is smart. If it sees that the initial set of commits that get pulled into the rebase are not getting modified, in any way, the rebase starts only with the first altered commit.
You'll need to look at your SCM in order to determine why it is including another commit in your PR.
If you can't figure out why your SCM is doing what it's doing, and what to do about it: note the hash of your surviving commit, cancel the branch, create a new branch, cherry-pick
the orphaned commit and attempt to do another PR.