That is because you are starting to work from a branch that is not yet merged into the main branch.... so, if you want to only see the changes of that specific feature that you are working on, you have basically 3 options:
Wait
... until the branch that you started from is merged into the main branch
Then you will only see your changes in the PR.
Rebase
... your feature on top of the main branch so that the revisions from the original branch are not part of the history of your branch anymore.... say that your feature branch has 4 commits:
git rebase --onto origin/main @~4 @
If you push now, the PR will only include the changes of your feature.
Of course, sometimes you depend on changes introduced on non-merged branches.... then you will have to use any of the other 2 options.
Use a different target branch (temporarily)
Set the PR to be merged into the branch of the PR that you started working from. Then the PR will show you only your changes. Then, when the branch that you started working from is merged, you can change the PR to point to the real main branch.
To wrap-up
Just in case, when you start working from another unmerged branch, you have to be extra careful if the base branch that you used moved (like a rebase is done on it) because if you then try to rebase your branch, you need to skip the revisions from the original base branch that you used (like I did in the git rebase --onto
). If you tried a simple rebase, those original revisions from the (old) base branch are not valid anymore will also be rebased, which you definitely do not want to do... unless you really (like really) know what you are doing.