So, I want to create a pull request that only includes the changes to file1, file2, and file3 (i.e. updates for a feature).
The workflow I used:
git clone https://github.com/eghm/project.git project-eghm-clean
cd project-eghm-clean
git remote add upstream https://github.com/forkeduser/project.git
git fetch upstream
git merge upstream/master
git push
git branch featurebranch
git checkout featurebranch
#edit files: file1, file2, file3
git add file1
git add file2
git add file3
git commit -m 'updates for feature'
git push --set-upstream origin featurebranch
Then on github I went to my forked repository, selected Branch: featurebranch, and clicked Pull request. The request includes my merges from synching my fork:
How can I avoid this in the future?
You should just git rebase
against the branch that you're issuing your pull request against. For instance:
git rebase origin/master
Since this will change the history of your branch, you are better off doing this rebase in a new branch. So:
git checkout -b new_rebased_branch
git rebase origin/master
For future reference, if you don't want merge commits in your pull requests, you should try to update your branches via rebase rather than merge. Again, I always recommend checking out a separate branch to do this in, since rebasing will change your commit history, you may want to keep a backup of the original commit history.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With