Development - Why Does my Pull Request Have Too Much Stuff?

Every time you create a Pull Request, it's a good idea to first review the code changes before hitting the Create button. If you're creating a Pull Request into a feature branch, you might notice that it has additional changes that you didn't make. If this is the case, please stop and do not create that pull request. You most likely have merged master into your branch, and now those changes from master are part of your new Pull Request.

You should instead merge master into the feature branch, then merge the feature branch into your own branch (with the changes from master) and then you may create your pull request.

You should do this in one of two ways:

Common start

  1. Make sure you have the latest copy of master
> git checkout master
> git fetch
> git pull

or (with fewer steps)

> git fetch origin master:master

2. Check out your feature branch

> git checkout master
> git fetch
> git pull

The Quick Way

  1. Merge master
> git merge master
  1. Push the changes
> git push
  1. Merge the feature branch back into your development branch.

The Safer Way

  1. Create a branch from your feature branch
> git checkout -b merge/123-xyz-master
  1. Merge in master
> git merge master
  1. Push the changes
> git push
  1. Create a pull request from your merge branch to the feature

  2. When that pull request has been completed, merge the feature branch back into your development branch.

Which One Should I Use?

If you're working on a feature branch with a team, it's better to use the second option, as it allows the team to review the potential changes to the current branch). If you're working by yourself or with only a few other people and you keep them posted about what's going on with merging master, you can use the first option.

No matter which path you use, as always with merges, make sure that (a) you have satisfactorily resolved all conflicts, and (b) that your solution still builds when you're done.

But I Already Created the Pull Request!

Simple. Just follow the steps as indicated below (whichever method makes more sense). Then, when your development branch is updated, push it to DevOps. Now, go to the Pull Request page for that branch and click "restart merge" (under the three dots at the right). This should make those additional changes go away.

Was this article helpful?
Thank you for your feedback!
User Icon

Thank you! Your comment has been submitted for approval.