How to undo a "Get Latest Version" on TFS - visual-studio

I'm using TFS with VS2008 and VS2010 and in the TFS collection I have several projects.
I've mapped the TFS root to a local drive to preserve the TFS folder structure and I've done a Get Latests of several subfolders.
I downloaded also an unwanted folder so I deleted the local folder contents but now in the TFS I see that folder in black and "Latest" Yes. How can I tell TFS that I've locally deleted a folder that I previously downloaded?

I think the problem is that you do not agree with TFS on what "latest" mean.
"Latest" in TFS mean that nothing has changed on the server since you did get latest. It do not mean that what is on the hard drive is equal to the latest version on the server.
So TFS shows what it is supposed to, see this question for more: Why doesn't TFS get latest get the latest?
The intended solution for folders on the server that you do not want to have on your local hard drive is "Cloak", as MBulava mentioned. (Right click folder -> Cloak). If you do not wish to have a folder on your hard drive I recommend this solution as it will never be downloaded until you uncloak it, and will show as greyed out and "not downloaded".
If you want to look at the differences between the contents on the hard drive and the server version you can use the "compare folders" feature. It will show that the folder is deleted on the hard drive.
If you want to get the folder mapped and grey (as the other folders you did not download) you can cloak it, and then uncloak it but answer "No" to downloading it now. This is equivalent to not downloading the folder in the first place.

Martin Woodward has a cool TFS Top Tip #11 - Removing source control files from your local file system blog post that answers this problem without resorting to cloaking.
You need to Get Specific Version, change the Version Type to Changeset and specify 1 for Changeset number. His blog post goes into detail about why this works. I've verified this behavior in Team Explorer for Visual Studio 2013, 2015 and 2017.
Update:
If you have got a bunch of folders to process you can use the command line as follows replacing folderName with the relative folder as the Client itemspec or the equivalent Server itempec:
tf.exe get folderName /v:1 /recursive

Mbulava's suggestion to use 'cloak' will leave the files and/or folders on the TFS server but will remove the files / folder from your local version and from the 'Get Latest Version' request.
If you have deleted files from your local directory and you then want those changes to appear on the server you need to go to the TFS director, select the files you want to delete, right click and delete the folders. Then you need to 'Check In' the pending deletion changes to the TFS server. TFS server will then delete the files / folders.

Related

Old drive expired and I'm trying to create a fresh Repo But I'm getting error -"Project not added to Subversion because it is out of working copy"

I have a project where the repository was on a disk that now is faulty.
so I have created a new repo folder in file explorer on a new disk.
I then deleted the .svn folder in my project as I thought that would make it like a fresh project (obviously I was wrong about that)
as It still wont add the project to the new repo with error "Project not added to Subversion because it is out of working copy"
It doesn't even ask where I want to create the Repo so somehow the project still has the old address.
I also altered my .sln solution file changing Svn-Managed to = False
The Old repo is gone and I'm using a backup that has been altered in the past.
Could anyone help me get round this please
Mike
I'm afraid that your case is unclear and maybe several screenshots and details about your environment will help (solution directories layout, versions of VisualSVN, TortoiseSVN, Visual Studio).
If you want to add your solution into a new repository, run the Extensions | VisualSVN | Add Solution to Subversion command and follow the steps of the wizard. If you receive warnings, please examine them and update your question with these details. Note that you need to svn commit your solution to publish your solution's data into a repository.
Additional notes:
Removing the .svn directory from a working copy effectively unties the directory from Subversion. I.e., this action unversions the working copy. Note that up-to-date VisualSVN and Subversion versions place only one .svn directory at the root of a working copy. But SVN 1.6 and older have this directory in every folder of a working copy.
If you want to re-add an existing solution to a new repository, then indeed you could remove the .svn directory or run svn export from the working copy into a new directory - this creates an unversioned copy of your working copy. Note that you may need to re-open your Visual Studio solution after removing the .svn directory.
The command Add Solution to Subversion is only active if the opened solution is not in a working copy (i.e., when it is not versioned). If the command is greyed out, then you need to unversion your solution first. See TortoiseSVN Manual | Exporting a Subversion working copy (section Removing a working copy from version control at the bottom of the page).
VisualSVN does not place the Svn-Managed to = False string into your solution's .sln file. VisualSVN does not depend on it. I assume that this string was recorded by another Visual Studio plug-in.

"Files already in version control are hidden" but I cannot find them them in TFS?

Steps I made leading up to this problem:
I created a project in Visual Studio Online (TFS) and checked in the entire contents (about 200mb) of a folder called classic.
I created another project and checked in the entire contents of a folder called dlls.
I decided that it would make more sense if these two folders were apart of the same project, so I deleted both of the ones I created in steps 1 and 2.
I created a new project and mapped it to a folder on my computer that contains both the classic and dlls folders.
In Visual Studio 2013, I go into "Source Control Explorer", right click and select "add existing item", and try to add both folders.
In this prompt, none of the files that I need to add are shown! The prompt gives me a message at the top that says "Files already in version control are hidden". If I click through each folder they are blank except for other folders. I verified that the files are still there on my local machine.
The problem is, I deleted those 2 projects in TFS that had the files. Do those projects still exists somewhere? How do I completely get rid of them? Where can I find those files at if they are "already in version control"?
This may be happening because even though you deleted the files from the server, you local workspace still thinks they are available on the server. The easiest way to recover is if you can delete your workspace and recreate it. Be careful not to delete your local files without creating a backup.

I deleted my working copy but TFS thinks I've still got it

I deleted a local copy of a TFS source-code branch (actually I renamed the branch and had to delete the old-named version), but Source Control Explorer window in Visual Studio says I still have the latest version so whenever I double-click a file, I get an error that the file doesn't exist.
Is TFS supposed to notice when I delete a local working copy i.e. this is a glitch?
How can I address it? Get the latest version and then delete it?
Is TFS supposed to notice when I delete a local working copy...?
No. TFS TFVC expects that it controls your working directories, at least with a Server Workspace. When you start doing things without telling it, then it has no idea.
If you want to remove files from your local drive, do a get of changeset 0 on that path (where the files won't be) and/or delete your working folder mapping or delete the TFS workspace.
Why does it work this way? Performance. If you have 10+ GB of sources, you can't afford to have your version control system scanning your filesystem to try to figure out what you've done. That's why TFVC Server Workspaces work this way.
Change your workspace to a Local Workspace if you have only a small bit of source code and you want to scan the filesystem for changes. Or switch to Git in TFS if you want a complete distributed experience.

Files missing from TFS restore

I've just created the simplest little project with a Program.cs file, checked it in to Visual Studio Online, deleted the project locally, and then tried to get the latest version from the online repository. The program file didn't download, even though Source Control Explorer shows it on the server:
Any idea why this won't download?
At this point there are no changes in the files since you last did a Get-latest to your workspace. Follow the below steps to get the files for your workspace:
Right click on the file/folder
Choose Advanced instead of Get Latest Version
Choose Get Specific Version
Check the "Overwrite all files even if the local version matches the specified version" box
This will force a download of all the files and not just files that have changed since the last time they were retrieved to your workspace.

TFS: View all unversioned files

How do I view all unversioned/uncontrolled files using TFS 2010 and VS 2010?
The problem that I am currently running into is after creating a new controller and view using the context menu (MVC3) I decided to roll back all those files by undoing the add in my pending changes window. I found that the files were no longer in TFS but are still on the disk. I would like to see the files that are currently on the disk but not versioned by TFS.
This is trivial in Subversion and Git (these files will always appear unless told to explicitly ignore them) but I am not seeing an option to view these in TFS - they do not appear under in my Pending Changes view. I am new to TFS so I assume I am just missing something.
If you are trying to determine all of the files which exist on your filesystem within a project folder that are NOT in TFS,
Open visual studio
Open Team Explorer (ctrl-w, m)
Go into "Source Control"
Navigate to the folder you want to find the unversioned files within.
In the top bar there is an icon with two folders and a magnifying glass between them, hinttexted "compare folders"
Compare "Source Path:" of whatever it suggests (probably server version) against "Target Path:" of your local version.
It will highlight all the differences within those folders. Any files which exist in the right hand (local) column are files which are not currently stored in TFS.
Team Foundation Server does not delete files when you undo the pending add for them - this is to prevent possible data loss. (It's possible, for example, that you want to create a file locally but not check it in to Team Foundation Server - since Visual Studio and Eclipse automatically pend this file as an addition, if it were to remove the files when you undid the add then there would be no way to have a file locally that didn't exist on the server.)
The Team Foundation Server power tools have to different operations that will help you sync up your local workspace with the server.
If you have files on disk that are not on the server and you want to update them (push them to the server), you can use tfpt online. This will detect all the files that were added or modified locally and create new pending changes to update the server. This is particularly useful if you've been working disconnected from the server and want to pend those changes.
If you have files on disk that you want to remove or otherwise update with the latest server version, you can use tfpt scorch. This will detect any files that have been added, modified or deleted locally and allow you to update them with the latest server version. If you just want to see the list of files and not actually take any action automatically, there is a preview mode you can use with tfpt scorch /preview.
Assuming that you have PowerShell installed, and tf.exe (from TFS Explorer tools) and sed.exe (GNU Tool) in your path, you could use this script (PowerShell) to do the work:
if((tf prop .) -ne $null) {
tf folderdiff . /r /view:targetOnly /noprompt | sed -e '/^=\+$/,/^=\+$/d; /^$/d' | %{
if(Test-Path $_) {
rm $_ -Rec
}
}
}
Actually, an pretty easy way to remove files/folders from your file system is to simply delete (or move) the local project folders then do a "get specific version" from TFS. Be sure to check both of the "overwrite" checkboxes.
It will then pull down everything that is currently stored in TFS.

Resources