TFS 2012 Unshelve to different branch -> An item with the same key has already been added

戏子无情 提交于 2019-11-28 03:05:41

问题


I need help resolving the following issue:

I am attempting to unshelve code from the source branch onto a target branch.

I am using the following:

  • VS2012 RC
  • TFS 2012
  • VS2012 x64 Cross Tools Command Prompt

When I use the command prompt to perform the unshelve operation, the following occurs:

  1. Shelveset details dialog gets displayed with list of change files.
  2. Click Unshelve button.
  3. Observe command prompt output: "An item with the same key has already been added."

I have downloaded ServicePack1 for power tools. However, I have failed to resolve this issue.


回答1:


I had the same issue and fixed it when I re-shelved the changeset from the source branch but chose not to preserve pending changes locally. After this the migration of the new shelveset ran smoothly.

(I also made sure I'd followed the below steps collected from other answers on this site)

  • Use a workspace that encompasses both source and target branches
  • Run the command from the folder mapped to the source branch
  • Check for quotes around any paths containing spaces
  • Deleting the cache in C:\Users[USERNAME]\AppData\Local\Microsoft\Team Foundation\4.0\Cache and restarting Visual Studio



回答2:


I had the same error when using Visual Studio 2013 and the following command:

> tfpt unshelve /migrate /source:"$/Root/Solution" /target:"$/Root/Branches/Solution" "The name of my shelveset"
> An item with the same key has already been added


Research

Here's what I tried to fix the issue:

  • Clearing the Cache as per Andrey's answer
  • Try running the command from the Source -> Branch and Branch -> Source
  • My workspace already encompassed both source and target branches


Solution

Open up your equivalent of the VS2013 x86 Native Tools Command Prompt.

  1. Check you have Team Foundation Power Tools installed:

    C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\tfpt

  2. Ensure you have 0 Pending and Excluded changes.
    I had some Excluded changes which were detected but not added and this is what caught me out. Excluded changes should look like this:


    Note: No "Detected: XX (adds)" - should not be visible
  3. When you run tf status, you should see something like the following.
    Either 1 change(s) for the .tfignore file or 0 change(s). Anything else will upset the merge.

    C:\tfs\Root\Solution>tf status
    File name Change Local path


    $/Root .tfignore edit C:\tfs\Root\Solution.tfignore

    1 change(s)

  4. Ensure you are running the tfpt command from the source Solution directory

You should be now be able to successfully merge a shelveset from one branch to another.

Note on .tfsignore:
If you have a lot of pending changes that you don't want to undo for whatever reason, then a modification to the .tfignore file is ok.

If this is the only file that you have left with changes, it won't brake the merge.
.tfignore reference => stackoverflow - How to ignore files/directories in tfs?




回答3:


Try to undo all changes on Source and Target branch and then try again...




回答4:


Try to delete all the files in the following folder and restart VS2012 (Source):

C:\Users[USERNAME]\AppData\Local\Microsoft\Team Foundation\4.0\Cache



来源:https://stackoverflow.com/questions/11978246/tfs-2012-unshelve-to-different-branch-an-item-with-the-same-key-has-already-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!