Renaming folders in TFS 2010 - tfs

What's the proper way (sequence of steps) to rename a folder in TFS? I tried doing it locally then commit but it's not working. I think you prob have to do it from TFS (server-side) instead right? But then if you do that and get latest then I guess it'll just update your folder locally and hopefully you don't have any other conflicts?

Open Source Control Explorer, mark your module, press F2 & enter the new name.
Module will appear in your Pending Changes window with Change type "rename".
Suppose you had a module named test.txt which participated in 3 changesets. It then gets renamed into itsatest.txt When I get History for file itsatest.txt I get this:
In my hard drive the test.txt doesn't exist after the rename.
The same principle works with folders as well.
EDIT after comment
Problem is I did all this renaming locally on my file system...I don't
want to lose all these changes because I also changed namespaces in
code, etc
I see. One way to proceed is to copy the entire directory somewhere out of your workspace. Then delete it from your workspace and retake it from source control with 'Get specific version' and 'Overwrite all files even if the local version matches the specified version'. Proceed with the rename & checkin.
Perform a directory compare between your locally stored dir & the one you 've just renamed. All your changed files should appear. Check them out & copy-paste them manually into your workspace.This should take care of the situation.
I'm pretty sure I remember another TFS SO post, where the recommendation was 'never mix pending changes with pending renames' - can't seem to find it ATM...

Related

Computer renamed - TFS Workspace doesn't work now

Had to change my computername and domain. Now I can't access team foundation. I tried this statement to fix it.
tf workspaces /updateComputerName:MyOldComputerName /s:"http://MyServer/MyCollection"
It didn't work. I get the following error "Key not valid for use in specified state."
Not sure what to do now.
It sounds like you may have a problem that will prevent remapping the workspace. However, it's possible that the command isn't quite correctly formed, so try checking the collection URL (I'd expect it to include MyServer:8080), and in versions of TFS 2010 onwards the documentation refers to /collection: rather than /s:
If that fails, then one approach to rescue things is to create a new workspace and delete the old one. You can transfer any edited files you had checked out to the new workspace as follows:
Rename your old source code folder, so you keep a backup
Create a new workspace that maps the (old) source code folder location, and Get the latest version of the code.
If you think you deleted or added files, use a folder-diff utility to find them, and manually re-do those changes.
Now check out everything (right click on the root folder and check it out)
Copy your backed up source code over your workspace folder
Undo checkout on everything. Visual Studio will ask if you want to discard your changes. Carefully choose the "No to all" option. This means it will only discard locks on unchanged files.
You will now have all changed files listed in your pending changes.
Once you're absolutely sure this has all worked, you can delete your backup of the source.
(You can achieve a similar thing by unplugging your network cable to force Visual Studio to go offline, moving your old source code back in place of your new workspace folder, then plug the net cable back in and using File > Source Control > Go Online. This should diff your code to the server and work out what changed. I don't trust this as much as the above approach though)
Once you have the code in your new workspace, you can use the tf command to delete the old workspace to clean everything up.

Delete Local Folder in TFS

I'm part of a large project mapped from TFS, within that project there is a folder which I have finished working on. I don't want that folder anymore so I'd like to delete my local copy. The problem is that TFS wants to mirror the change and delete the folder from source control, I don't want to remove it from TFS.
The only way I can find to do this is to unmap the workspace, and then go through and get all the other folders I need to work on.
Is there anyway I can just delete that folder locally?
This is an older post, but since the only given answer seems "not entirely correct" to me I'd like to answer anyway:
I blogged about this (in german) here: blog.nils-andresen.de
If you have a local copy, that you want to un-get or un-download like this:
simply right-click the folder and then click "Get Specific Version" or "Advanced > Get Specific Version" and specify Changeset 1.
Here's why from Martin Woodward's TFS Top Tips:
...if you do a "Get Specific Version..." on the files, and select Changeset 1, the files will be deleted locally and the server will know this. The color of the file in the Source Control explorer will go from black to gray and will have the phrase "Not downloaded" in the latest column.
Changeset 1 is a special changeset on your Team Foundation Server instance. It was created as part of the setup routine and only contains one thing - the root node ($/) in your source control tree. If you do a get for Changeset 1 on any actual files then they will not exist at that point in time on the system so will be deleted locally and the server will know this.
When the process is complete the "Latest"-column will show "not downloaded".
After that any remaining files in the filesystem can safely be removed.
You can cloak the folder in your local workspace.
By setting the working folder status to Cloaked, you can specify that a local folder should not copy files from the server when you perform a Get operation. You might choose to do this to conserve space on your local disk. If you later decide that you need to get files in those cloaked folders, you must change the status to Active and then perform a Get operation.

Latest value = "Not Downloaded"

I have several projects in TFS which visually appear in the directory hierarchy as grayed out. When I browse within the projects in Visual Studio 2010/Source Control/TFS 2010, I notice that all of their contents have a Latest value of "Not downloaded". Normally, I have only seen Latest values of "Yes" or "No".
I have tried all of the varieties of "Get latest" that I know, but I am always alerted that "All files are up to date".
If I try to "Check out for edit", I am not allowed.
When I observe the properties of these grayed out files, they always say Workspace Version = "Not applicable".
How do I fix TFS so that I can download and check out the projects again? My suspicion is that my workspace is messed up, but I do not know what to do to restore/reconfigure it.
I was able to remap the directory to fix my issue. To do this, I
selected (right-clicked) the branch that included all of my code, and selected "Remove Mapping..."
renamed the folder I was mapped to within TFS (you can delete it as well, but I renamed just to keep it during this experimental process)
created a new folder with the original name of the branch I was mapped to in the beginning, and
selected (right-clicked) the branch that included all of my code, and selected "Map to Local Folder".
This process forces a complete re-download of the entire branch. Luckily for me, my branch was only 2GB, so I was able to re-download in about 5-10 minutes.
The reason for getting "All files are up to date" - is that the information on the TFS server and the files on your disk is out of sync. If you delete the files on your disk with file explorer - the TFS server still thinks you have the file on disk. To re-sync you have to force an update like this:
Check the two checkbox on this dialog - and click Get:
It happened to me as well when I added and existing project as a reference to another project.
When I added the project reference I had a pop-up message that told me that the current project already exists at the source control but at a different location then the relative path of the current project.
by a mistake I choose the wrong option which lead to the unnecessary mapping.
In order to solve this issue I've removed the mapping from the workspace.
only after removing the mapping i could get the latest project.
I solved it by following this - remove the work space and then tfs prompted me to download everything again.
https://msdn.microsoft.com/en-us/library/ms181386(v=vs.100).aspx
It sounds like the folders / files in TFS are not mapped to a local drive in your workspace.
In Source Control Explorer, select the "Workspace:" dropdown, then select "Workspaces".
Choose your current workspace form the list that appears, then hit "Edit". Check that the TFS folder $/blah is mapped to a local folder c:\tfs\blah
You should now be able to get latest, check out etc.
I had some weirdness with this after :
updating to TFS2017
updating to VS2017
trying to change my TFS URL to https (gave up and reverted back to http)
So somewhere along the line this broke my workspace such that all my projects were showing as unbound. I was able to do a get latest again. This should not overwrite any files you have changed providing they are writable, but if you have any doubt whatsoever then backup your local workspace before doing get latest. It will ask you to resolve conflicts - so make sure to select 'keep local copy'.
In my case, when the branch was deleted: Right click + Check in, helped.

Manually update files

Scenario:
A solution is checked into TFS. Changes are made to an offline/disconnected/unbound copy of the solution, which becomes "the latest" version. I want to update the repo with this disconnected copy's files.
How do I get TFS to look at all the files and determine which ones have changed, so it can check only those in?
If this were SVN, I would just plop the files on top of the existing working copy, and it would just work.
Do you have another copy of the solution that is bound to TFS? If not, you'll need one. You have two options:
Take the solution "offline" by right-clicking on the solution node and click "Go Offline". You can then copy your changed solution on top of the bound solution. When you load the solution again, right-click the solution again and choose Go Online. This will scan the disk and determine what has changed.
You other options is to run "tf edit" recursively on a bound solution, copy your changed solution on top of the bound one and then run "tfpt uu". "uu" stands for undo unchanged and it will undo changes to the files that are not different.
I cant think of any elegant way off hand but your best option would be to know what files were changed or added offline and connect them to the TFS version while removing the old TFS files.
To do this simply right click all of the old files and either delete them or exclude them from the project then move the new files into their physical folders and replace them with the updated version. If files were added then add them in the correct folders. Finally make sure all files are view-able in the solution explorer by clicking "show all files". Finally, right click the files you changed and select include in project for each.
This way you will have replaced only the files that were changed and won't have to check in the entire solution to TFS making it very unclear what files were changed with your check-in.

TFS: How to merge only changes on my shelve, without overwriting local copy enterily

I'm trying to find a way to merge shelve changes with the latest version I have locally without overwriting my local files with those of the shelve.
That is, I have a shelve from date 0, on date 1 some changes were done in the tree, on date 2 I do a Get Latest Version, then when applying the shelve, changes of date 1 get lost.
No merge conflict between changes in date 1 and those of my shelve.
Ideas? Thanks!
Finally, what I ended up doing was to
1) "get specific version" to the date when changeset was taken
2) "get latest version".
That way, TFS merges latest version with changed local files. (The other way around -what I was looking for- seems not possible).
Two options spring to mind:
(Advice: Before you start, back up your code, in case there is anything in there that isn't safely stored on the server or in a shelve set!)
If you unshelve first, you will end up with locks on the shelved (0) files.
Then GLV to get the (1) files. All the files you have locked will be merge conflicts, which you can then resolve, test, and check in as normal.
Get the shelved code and copy it to another folder on your hard drive. Then GLV the latest server code. Check out the files you have changed (or easier, the root folder), and then manually merge the two sets of sources. You can then "undo check out" to get rid of the unchanged files (say "no" to the "discard your changes" question and it'll keep locks only on changed files) and after testing that your code works, check in the resulting changed files.
You need another Workspace, that is a local folder were your working copy resides (Yes, you can have more than one).
With a fresh Workspace with no changes on it, you could recover your shelve there, do the check-in, and have your original workspace untouched. Optionally, you could delete the alternative Workspace, or keep it for these kind of maintenance tasks.
For creating a new Workspace, just open the Source Control Explorer and open the Workspace combo-box on the upper toolbar. Select Manage Workspaces and create a new one from there.

Resources