As title says, I have an open PR with my changes in it. I want to pull in master
branch but I don't want it showing as new changes in my PR for reviewers to have to sift through and ignore. What is the best way of doing this?
CodePudding user response:
Just do it. If, in your PR branch, you say
git fetch
git merge origin/master
git push
You will bring your PR branch up to date, but the PR on GitHub will not display new "changes" from master in its diff.
CodePudding user response:
I want to pull in master branch but I don't want it showing as new changes in my PR for reviewers to have to sift through and ignore.
I prefer git rebase
in these situations. Rebasing effectively stashes the new commits in your branch, updates your branch to look like the one that you're rebasing from, and then adds the stashed commits back to your branch. The result is that your branch looks like you made your changes starting from a current copy of the branch you rebased from.
Now, some folks would object to the idea of rebasing a branch from which you've already made a pull request, because your branch is now "public," i.e. the reviewers may have already pulled down copies, and rebasing your branch after that happens makes your branch's history different from the one they've got. That's a valid concern, but in practice it's easy to avoid problems, especially in a small-ish team, by just letting the reviewers know that you've rebased the PR.
As a git user, you should have a clear understanding of the difference between rebase
and merge
so that you can make informed decisions about when to use each. Fortunately, Atlassian has an extensive but easy to read article called Merging vs. Rebasing on that very topic.