Matt Rowett Matt Rowett - 1 month ago 7
Git Question

Previous commits added to Team Services Git Pull Request

We're using Team Services and Git, after completing a Pull Request from branch to master (selecting Delete and Squash the branch) the branch disappears from Team Services...Code...Branches, so far so good.

The next time a user pushes a commit to a new branch with the same name and creates a Pull Request, we see the commits and files from the previous Pull Request automatically attached to the new one which makes code reviews very difficult. Is this intentional behaviour or are we doing something wrong here?

Answer

The reason is that the local branch contains all history records, so the history records (include commit before that pull request) will be included in the remote branch when you push a commit to a new branch with the same name. You can delete local branch and pull latest data from remote master branch to local master branch, then create a new branch from local master branch.

Steps:

  1. Delete related local branch
  2. Switch to master branch
  3. Pull data from remote master
  4. Create a new branch (name could be same as deleted branch) from local remote master