0

Here is the workflow I've been attempting, after watching a this Git/TFS video.

So I create a branch from my development branch

$ git checkout -b my-feature-branch development

Then I make a change, stage, commit, and push the changes up to the TFS server.

Now when I go to the TFS web interface, I have a "my-feature-branch" on the server.

I click "New Pull Request" and create a PR into development, and Accept this PR. This process deletes the "my-feature-branch" on the TFS server, but it remains on my local machine.

Everything is great at this point.

Back to my local machine, switch out of the feature branch:

git checkout development

Delete the local branch

  git branch -d my-feature-branch

warning: deleting branch 'my-feature-branch' that has been merged to
         'refs/remotes/origin/test-pr', but not yet merged to HEAD. Deleted branch my-feature-branch (was d525adc).

Get latest -

git pull -p

Sometimes, and I may be doing the pull prior to the delete, the delete Fails and I have to Force Delete it.

git branch -D my-feature-branch

Is my workflow wrong? Should I be doing some kind of merge prior to deletion? Why doesn't git know the feature branch has been merged in as a Pull Request after the pull and let me delete without error?

1
  • 1
    What does the local development branch's history look like, in gitk or tig, when the failure is reported? Commented May 21, 2019 at 20:12

1 Answer 1

0

Why doesn't git know the feature branch has been merged in as a Pull Request after the pull and let me delete without error?

It’s hard to know from the information you’ve supplied, but here are two guesses:

  1. Are you sure you’re pulling before deleting the local feature branch? If you’re not, then of course the main branch won’t have the new commits.

  2. How are you merging the feature branch in? With a regular merge or a squash merge? A regular merge incorporates the feature branch commits into the main branch, so that Git knows it’s all there. A squash merge, OTOH, incorporates all the content from the feature branch, but does so by creating a new commit, and Git does not track the fact that the new squashed commit was generated from the feature branch commits, so it doesn’t think that the feature branch was merged in.

(I strongly recommend not using squash merges. Keeping the original commits, as a standard merge does, helps make Git work better.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .