37

I am follwing the example here Branch from local workspace because I have the same scenario.

Shelveset details dialog appear, after clicking unshelve it showing "An item with the same key has already been added."

Any advice please?

Community
  • 1
  • 1
NetZeroSaw
  • 481
  • 4
  • 5
  • 10
    Solved by Undo pending changes from Main as well. Here's help link. http://www.lemisolutions.co.nz/2013/07/creating-branch-out-of-your-pending.html – NetZeroSaw Jul 24 '13 at 04:41
  • 2
    could you accept an answer, since people have put the effort into your question? – Ralph Willgoss Nov 30 '14 at 11:46
  • 1
    @RalphWillgoss It seems he solved it himself on 24-Jul-2013 itself! Other answers (later in 2014) seems to be similar to his comment. – Sen Jacob May 29 '17 at 09:50

3 Answers3

33

As others have indicated in the comments, undoing changes from the main branch (presumably the SOURCE branch for the shelveset you want to unshelve), should fix the issue, allowing you to continue with the merge behavior.

JoeBrockhaus
  • 2,745
  • 2
  • 40
  • 64
  • 10
    In fact you need to undo / shelve changes from other repositories. The included / excluded / add sections should be completely empty for this to work. – Gabriel Mar 19 '15 at 23:27
  • 2
    @Gabriel's comment is vital. If you have any file in Include / Excluded / Add, from *any* part of the team project, you will get this error. Strange but true. – ngm Dec 08 '16 at 15:05
5

I had a very similar issue to yourself and after trying a lot of things I discovered it was some pending changes we had been excluded and were easy to miss, that caused the issue.

I've written up how to trouble shoot it against the following question:
TFS 2012 Unshelve to different branch -> An item with the same key has already been added

Community
  • 1
  • 1
Ralph Willgoss
  • 11,750
  • 4
  • 64
  • 67
1

In my case, my source and my target branch were both fully checked in. The problem was the root Team Project had other Visual Studio projects beneath it with pending changes (pending adds). There can be no pending changes in the entire TFS Team Project, not just the involved project branches.

xr280xr
  • 12,621
  • 7
  • 81
  • 125