User Story changes and commits appear on master or destination branches without deploying the user story.

If you notice that some of your branches in the pipeline or the master branch contains commits and changes that belongs to user stories that were never moved to the environments for these branches, this is probably the reason.

When committing on a user story, if the Base Branch feature is used to create the feature branch from a branch different than master, the feature branch will contain the commit history of the branch selected.

Let's supposed you have this flow:

Dev1 => INT => UAT => Prod

US-01 is created in Dev1 and commit is done with master as base branch.
US-01 is moved to INT. The commit made on the user story is now part of the commit history of INT branch.

US-02 is created in Dev1 and commit is done with base branch INT.
Feature branch for US-02 contains the commit made on US-01 since the US-01 was moved to INT.
US-02 is moved to INT. 
US-02 is moved to UAT. Now UAT has the commit of US-01 even though US-01 is still on INT.

When the US-02 was moved to UAT, what happened during the merge of the feature branch of US-02 into the promotion branch created from UAT?

When a user story is promoted, Copado will ask git to perform the merge of the feature branch into the promotion branch. Git will try to merge branches, not specific components. This means that git will compare the branches and will try to merge the changes for all the commits ahead in the feature branch in comparison with the target branch (promotion branch). Two things might happen on this process:

1. For the files with no conflicts, git will perform the merge and the changes from the commits ahead will be merged no matter if the files are part of that user story or not.
2. For the files returning conflicts, Copado will auto resolve them and will only merge the files if they are part of the user story.

Note that, even if there are conflicts in some files and they are not merged by Copado, the process of merging the 2 branches is completed and the commit history is merged what means that your target branch will contain all the commits of the feature branch.

How did we do?