Pull request shows changes unrelated to the components committed on the user story

When using the pull request feature on user stories, it's important to understand the following.

If you do a pull request between your feature branch and the target branch, you will see the result of comparing these 2 branches where the target branch is set as the base branch in the comparison. The result of that comparison will show you not only the changes applied in the latest commit in the feature branch but also the changes related to any other commit ahead in that feature branch in comparison with the target branch.

Ideally, the only commits ahead of your target branch should be those that were created when committing in that user story and the pull request would only show you the differences in the files that were modified in those commits. 
It might happen though, that the feature branch, which is created from the master branch, contains some other commits that are ahead of the target branch and the changes applied in these other commits will be also shown on the pull request.

There are two reasons why the master branch (and therefore the new feature branches created from it) might have extra commits that don't exist in your lower branches:

Reason #1

The commits were done on the master branch and they were never back promoted to the target branch in your pull request. The feature branch created from the master branch will contain these extra commits. The commits made on the user story will be added to the commits made in the master branch and all of them will appear in the pull request.
The commits could have been created in the master branch as part of:
  1. A manual update directly in the branch.
  2. A manual update in the promotion branch used in a production deployment.
  3. A deployment from a Hotfix environment connected to production.

Reason #2

When deploying to production there might be conflicts that are resolved:
  1. Automatically by Copado with the auto-resolve feature.
  2. By a developer with the online conflict resolution tool in Copado.
  3. With the smart conflict resolution using a previous resolution for the same conflict.

The resolution of the conflicts will be applied to the branch with an extra commit that eventually will be added to the master branch when the deployment to production is completed. The commits generated are unique and they only exist in the master branch.

When new user stories are created in the lower environments of your pipeline, the pull request between the feature and the target branch will show those extra commits created for the conclicts resolution since they are commits ahead in the feature branch that don't exist in the target branch.

This extra commit will show the changes that were made when resolving the conflicts in those specific file(s) and they will be unrelated to the components and/or changes in your user story. The changes shown in that commit already exist in the target branch what means those changes are not really applied when merging the feature into the target branch. It's just the pull request git feature showing what changes were applied in those commits.

How did we do?