I keep running into problems with git in a common workflow on GitHub.
This is where the problem arises: my pull request now contains all the changes that occurred between steps 2 and 7, including the upstream developer's own changes. In a recent example this expanded a 10-line pull request to over 12,000 lines.
How should I reapply my original commits onto a later version of the upstream repo without their changes getting into my pull request?
Adding a pull request to a merge queueOn GitHub.com, navigate to the main page of the repository. Under your repository name, click Pull requests. In the "Pull Requests" list, click the pull request you would like to add to a merge queue. Click Merge when ready to add the pull request to the merge queue.
Change this
7) I fetch & merge changes from upstream into my repo, resolve conflicts, commit changes.
8) I rebase commits in my pull request to make it neat and tidy.
to
I rebase my repo onto upstream, making it neat and tidy.
We'll assume you forked the feature
branch from upstream/master
, and we'll use a temporary branch to be safe. If things go wrong, just delete the feature-rebase
branch and start over.
git checkout feature
git checkout -b feature-rebase
git rebase -i upstream/master
This will replay your commits on top of upstream/master
, as if you had forked right now. Once everything looks good, replace the old feature
branch with the rebased version.
git branch -m feature feature-old
git branch -m feature-rebase feature
git branch -d feature-old
git checkout feature
git push -f origin feature
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