Why Do I get another team member commits for my Branch pull request

Viewed 3791

In Bitbucker I get other person commits along with my commits for my branch pull request.

  1. Create two branches from master branch.(Assume A & B)
  2. In Controller Class added two different functions for same line by two members. (I and my friend added separate new function for controller class in two separated new branch)
  3. Created pull requests for master branch by two branches A & B.
  4. Approved branch A to merge request.
  5. Branch A merged to master.
  6. Branch B get conflicts.

Tried To Resolve Conflicts Branch B

  1. Checkout to master
  2. git pull
  3. checkout to Branch B.
  4. git rebase master
  5. added new function to controller next to A branch function.
  6. git add
  7. git commit

Get an error ##

error: failed to push some refs to, hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again.

Resolve

  1. git pull --rebase
  2. git add
  3. git commit
  4. git push

Then now I get other team member commits in my commits list mentioning as a "merge pull request" Now I can not continue merger request to master branch. I got error message from bitbucket,

"The merge could not be completed because the repository is configured to require fast-forward merges and the target branch contains commits which are not present in the source branch. To perform this merge, either merge 'master' into 'vp-42', or rebase 'vp-42' onto 'master'"

1 Answers

You should, rewind to step 7 and then git push --force.

You've changed history of branch B, and your local B is the new official history. You don't want to integrate the remote B into your local B - you want to overwrite the remote B branch.

Related