-->

Change computer name for a TFS Workspace

2019-01-20 23:50发布

问题:

My System Administrator renamed my computer. So where it was "MyLaptop2" it is now just "MyLaptop".

So now all my source control bindings and checked out files are looking for a workspace with "MyLaptop2".

Is there a way to redirect that workspace to my renamed (but still the same) computer?

回答1:

This command run in the Developer Command Prompt for Visual Studio did the trick:

tf workspaces /updateComputerName:MyOldComputerName 
/s:"http://MyServer:8080/tfs/MyCollection"

It had to be run from the computer I wanted to assign the workspace to (that is how it gets the new computer name.



回答2:

Vaccano's solution worked for me. It took me several tries to get the TFS URL right, so I thought I'd post it for those of you who are using Microsoft's Visual Studio TFS hosting (currently free for small teams).

From a command prompt on my computer, I first changed to the right directory:

cd c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE

Then I ran the command:

tf workspaces /updateComputerName:OLDCOMPUTERNAME /s:"https://MYCOMPANY.visualstudio.com/DefaultCollection"

It then told me that my new workspace matched the machine name of my new computer name.

Hope the path helps.



回答3:

I tried running the commands mentioned in the other answers; however, my project is hosted in TFS online (visualstudio.com) so I needed to authenticate first since I kept getting this error message:

TF400813: Resource not available for anonymous access.

For me it was just easier and much faster to remove the worskpace and reconnect again:

File > Source Control > Advanced > Workspaces (remove workspace)



回答4:

Go to VS command prompt and type the following:

tf workspaces

This will provide you with the available Collections. Copy the path (essentially a URL) of your intended collection. Then type the following:

tf workspaces /updateComputerName:"OLD_NAME" /collection:"The URL copied from above"

(exclude the quotes above)



回答5:

Vaccano was correct, however, I needed the workspace name after the UpdateCompterName switch. In my case the workspace was the old machine name.

If you don't know your workspace name you can find all workspace names using:
tf workspaces /owner:* /computer:* /server:http://MyServer:8080/tfs/MyCollection

So I ended up with the following.
tf workspaces /updateComputerName:MyOldComputerName MyOldComputerName /s:http://MyServer:8080/tfs/MyCollection



回答6:

Given below how it worked for me.

Step 1. Go go Visual Studio Command Prompt

Step 2. In above command prompt type command tf workspaces. This command will show all the workspaces you created in your machine and also the collection name. Look carefully for first line of the result of the command.

Step 3. In same command prompt type command tf workspaces /updateComputerName:OLDCOMPUTERNAME /s:"collection name as shown above"

The OLDCOMPUTERNAME AND COLLECTION NAME ARE VERY IMPORTANT HERE.



回答7:

If someone don't feel so comfortable with CommandPromt (like me) This Infographic post can help you . here is the text snippet from the blog:

Click on FILE menu on your Visual Studio 2013. Now click on

Source Control -> Advanced -> Workspaces..

This will open a window with title "Manage Workspaces". It shows the list of workspaces on this computer to which you have access. The list contains 4 columns for:

  1. Workspace Name
  2. Computer
  3. Workspace Owner
  4. Comment (if added while creating workspace)

Add Workspace: If Workspace Manager is empty, probably you didn't added one yet. Click on Add button and put your server/ username/ password and it will list the added one for you.

Update Workspace: Later if you have changed your computer name or anyway you want to update your workspace accordingly, select the workspace you want to edit and click on Edit button; here you can update your workspace details.



回答8:

Just to clarify for users of TFS Online (MS hosted TFS) - if your url was "mytfs.visualstudio.com" and your collection is "DefaultCollection", the commands as listed above will be:

To list all workspaces: tf workspaces /owner:* /computer:* /server:https://mytfs.visualstudio.com/DefaultCollection

To update from OldPcName: tf workspaces /updateComputerName:OldPcName /server:https://mytfs.visualstudio.com/DefaultCollection

In short, specify HTTPS, ignore the port and don't add a /tfs/ folder structure.

You can then select (and rename if desired) the workspace by going to source control explorer and using the Workspace drop down.



回答9:

In Visual Studio.. Go to "Team Explorer-Home" ... you will be able to see your workspace name.. Click on it and "Manage".. Add your workspace.. This should do the trick..



回答10:

To avoid get and map after creating new workspace

  1. Run cmd

  2. Navigate to visual studio IDE path. Something like this:

    C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE
    
  3. Run this command:

    tf workspaces /updateComputerName:MyOldComputerName /s:"http://MyServer/tfs/MyCollection"
    
  4. In "manage workspace", delete the added workspace (named as your current computer name), and rename the old one to your current computer name.

In this scenario you don't need any extra get and map.



回答11:

Answer by user: open and free worked for me. File -> Source Control -> Advanced -> Workspace

This will open a window with title "Manage Workspaces". Tick "Show remote workspaces" which showed the workspace that was blocking on of the .cs file changes. I removed and I am working fine now :)



回答12:

I had the same problem and came here. But then I just closed and reopened visual studio and it was fine. So... that might be the solution for some.



回答13:

To expand on some earlier answers, my collection name had some spaces in there. Even if the collection name is surrounded in quotes ("http://1.2.3.4:8080/tfs/My Collection Name") you need to replace any space characters with %20 to resolve the name properly (tf workspaces /updateComputerName:MyOldComputerName /s:"http://1.2.3.4:8080/tfs/My%20Collection%20Name")



回答14:

I had to do this in the Developer Command Prompt for VS:

C:\Program Files (x86)\Microsoft Visual Studio 14.0>tf workspace /delete /server:http://tfs.mysite.com:8080/tfs/defaultcollection devshed22;Warren



回答15:

  1. Make a copy of project folder
  2. Map original local folder in TeamExplorer/SourceControl
  3. Set read-only attribute to original local folder and sub-folders
  4. Load project from original folder, Go online and Get latest version. Local files will be overwritten.
  5. Close solution, delete original folder, restore copy with original folder name
  6. Open solution, Go online and you can check-in files without conflicts.