TFS creates a $tf folder with gigabytes of .gz files. Can I safely delete it?
Asked Answered
J

4

52

I am using visual studio 2012 with Microsoft TFS 2012.

On the workspace that is created on my c: drive, a hidden folder $tf is created. I suspect TFS from creating this folder. It's lurking diskspace as the current size is several gigabytes now and it's about 25% diskspace of the total amount of gigabytes needed for the complete workspace. So this hidden $tf folder is quite huge.

The structure is like this:

c:\workspace\$tf\0\{many files with guid in filename}.gz
c:\workspace\$tf\1\{many files with guid in filename}.gz

Does anyone know if I can delete this $tf folder safely or if it is absolutely necessary to keep track of changes inside the workspace?

Jarodjarosite answered 23/5, 2014 at 9:1 Comment(1)
To get rid of this during the Publish Arifact step of a VSTS build you can just exclude it during a copy files task. More here: github.com/Microsoft/azure-pipelines-agent/issues/859Earle
F
66

TFS keeps a hash and some additional information on all file in the workspace so that it can do change tracking for Local Workspaces and quickly detect the changes in the files. It also contains the compressed baseline for your files. Binary files and already compressed files will clog up quite a bit of space. Simple .cs files should stay very small (depending on your FAT/NTFS cluster size).

If you want to get rid of these, then set the Workspace type to a server workspace, but lose the advantages of local workspaces.

Deleting these files will be only temporarily since TFS will force their recreation as soon as you perform a Get operation.

You can reduce the size of this folder by doing a few things:

  • Create small, targeted workspaces (only grab the items you need to do the changes you need to make)
  • Cloak folders, exclude folders containing items you don't need. Especially folders containing lots of large binary files
  • Put your dependencies in NuGet packages instead of checking them into source control..
  • Put your TFS workspace on a drive with a small NTFS/FAT cluster size (a cluster size of 64Kb will seriously enlarge the amount of disk space required if all you have are 1KB files.

To setup a server workspace, change the setting hidden in the advanced workspace setting section: enter image description here

Fart answered 23/5, 2014 at 9:17 Comment(2)
This works. I did try server level, but now I realize that it was on the wrong level. When opening one project collection there is also the possibility to work on server level by setting the option in: Team Explorer > Settings > Team Project Collection > Source Control > Workspace Settings > Server, but that is not on the entire workspace. With your solution it is much better.Jarodjarosite
That setting sets the default for new workspaces, but existing workspaces will remain on their original configuration. You can even set it to Local, independently of the Project Collection Settings. I prefer Local workspaces though, just the removal of the read-only bit is enough for me :).Fart
T
8

The simple answer: I deleted the $tf files once: the net result was that newly added files showed up in my pending changes, but when I changed an existing file, the change did not show up in my pending changes. So I would not recommend deleting this folder.

Thrombin answered 31/10, 2014 at 15:46 Comment(1)
Where is this $tf folder?Ullund
C
2

To answer the original question, the answer is yes. However, in order for TFS to track changes, it will need to be recreated, albeit with fewer folders and much smaller disk space. To do that:

  1. First delete all the tf$ folders currently in your current workspace folder.
  2. Next, move all of the remaining contents of the original folder to another empty folder, preferably one on another drive;
  3. Perform a "Get latest" into the original (now empty) workspace folder (this will cause a single tf$ folder to be created in that original folder).
  4. Now copy all of the contents you moved into the backup folder over the top of the 'Get latest' results in the original workspace folder.

By performing these steps in that order, you will end up with the tf$ entries TFS needs, but in a single folder and much more compact - additionally, the deltas of any changes you made that had not been checked in will be preserved and TFS will recognize them as pending changes as it should.

Our Certitude AMULETs C++ solution has 72 advanced projects in it, and we have to do this once a month to keep compiling and search speeds reasonable.

Chindwin answered 18/12, 2016 at 19:26 Comment(0)
P
0

I deleted the $tf directory, and GetLatest behaved - it asked me if I wanted to keep the local files or replace with server. I could then check as normal. The mildly annoy part was about 30 files I had locally that I had told to ignore appeared.

Pm answered 28/6, 2022 at 20:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.