You can simulate the behavior you want, but what happens to the changes you make to the third file?
Changes in the third file remain in the commit on the branch, but they will not be present in the combined commit, since the file was not changed at all in the branch.
Here's how you can do it:
git checkout master git merge bugfix --no-commit
The --no-commit tells git merge the files, but stops before they are executed. Now you can check files, modify them, do whatever you want. To undo the changes you made to index.php , you can run:
git checkout master -- index.php
By running git status , you can see that index.php no longer appears as changed (neither in the index, nor in the working tree). Now you can git commit and that’s it.
source share