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.

A commit on a user story will make changes in the feature branch for the components selected during the commit. After committing components in a user story, if you want to see the changes that were applied to the feature branch for that specific commit, you should check in git that specific commit in the feature branch. You can navigate to the commit in the feature branch directly from the user story record to see what was changed.

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 any other commit ahead in that feature branch in comparison with the target branch.

When a pull request compares branches, it's looking at the commits ahead in the feature branch in comparison with the promotion branch. This means that you could be looking at changes that were done in the feature branch in other commits, not only the commit that was done in the user story.

Ideally, the only commits ahead of your target branch in your feature 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 shown on the pull request which is expected.

The reason why the feature branch might have other commits ahead of the target branch is that some commits where done on the master branch and they were never back promoted to that specific target branch you are comparing with. This is causing the feature branch to have commits ahead of the target branch since the moment it's created. The commits on the user story will add more commits ahead and the changes in all of them will be shown on the pull request.


How did we do?