52

Is there any way I can add an existing folder to source control in TFS? I have created a new folder outside of TFS, just in the file system, and would like to add it to source control, but the only apparent way to do this is the ridiculous workaround of renaming my new folder to a temp name, then creating the new folder in Source Control Explorer, then adding the items from my renamed, original new folder.

ProfK
  • 49,207
  • 121
  • 399
  • 775

3 Answers3

53

Just select the folder after selecting the "Add Items to Folder..." option. You can get to this is from the context menu you get when right clicking on a folder (either the name or the actual folder itself).

The next page of the wizard will present you with lists of included and excluded files. Select the files you want and then hit "Finish".

Then submit the pending changes.

Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
ChrisF
  • 134,786
  • 31
  • 255
  • 325
  • 1
    N.B. having played around a bit with trying to get TFS to SC empty folders... it seems you can't which is really annoying. e.g. I have SquishIt running and it needs a specific folder when the deployed version hits the server, so it has somewhere to place its runtime created combined css / js files. seems I need to check in a dummy file, or one of the existing files to have TFS recognise the folder, and include it in the deploy. Very silly. We shouldn't have to trick our source control like this really... :( – MemeDeveloper Jan 23 '12 at 01:09
  • 22
    Just to clarify: **Add Items to Folder** is a button on the toolbar of the Source Control Explorer. I was unable to find it based on this answer and accidentally found it reading another article. – toddmo Oct 22 '12 at 19:39
22

Let me share you a easier way that I just figured out. (I was having the same trouble, and that is why I found this post.)

Drag the folder you want to add to the solution explorer and drop at the place you want to add.

Ta Ta ! It is done.

Mine is VS2010.

maxisam
  • 21,975
  • 9
  • 75
  • 84
  • 1
    thanks, that worked perfectly just remember to bind all the solutions and projects that you add, VS will prompt, click the solution/project and "bind" – rob May 02 '12 at 14:41
  • That only works if the location you want to add the folder to is inside a solution. It is perfectly legal to have files/folders under source control that aren't part of a Visual Studio solution. – LeonZandman Dec 02 '14 at 12:17
  • @LeonZandman ah... It works in both cases, at least in my environment.(win7 + VS 2013) – maxisam Dec 02 '14 at 15:27
  • @maxisam Maybe we are talking about two different things? The *Solution* Explorer only shows stuff that's inside your Visual Studio solution. Therefore you can only drag/drop things into the solution it currently displays. The *Source Control* Explorer is a different window. It shows the complete TFS contents and can be used to add stuff to arbitrary locations. The answer to this question thread would be for him to use the Source Control Explorer. Your answer however talks about the Solution Explorer and I don't think that's correct. – LeonZandman Dec 03 '14 at 16:03
  • 1
    @LeonZandman I see, We were talking on different thing. However, this trick works on both cases. In Source Control Explorer, it will just pop up one more window asking you what files do you wanna add to source control. – maxisam Dec 03 '14 at 17:20
4

Before dragging and dropping or selecting Add Items To Folder, you must map the parent TFS folder to your local drive.

That is, if you want to add a C:\Stuff\HelloWorld directory to the /Top/Projects folder in TFS, you must first map /Top/Projects to C:\Stuff and then add HelloWorld.

António Almeida
  • 9,620
  • 8
  • 59
  • 66
Ian
  • 41
  • 1