Udostępnij za pośrednictwem


Add Command

Adds new files and folders from a local file system location to a Team Foundation version control server.

Note

The results of this command are not reflected in the Team Foundation version control server until you perform a check-in operation. For more information, see How to: Check In Pending Changes.

Required Permissions

To use the add command, you must own the workspace and have the Check out permission for the parent folder of the new items set to Allow. You must also have the Lock permission set to Allow if /lock:checkout or /lock:checkin is used. For more information, see Team Foundation Server Permissions.

tf add itemspec [/lock:none|checkin|checkout] [/type:filetype] 
[/noprompt] [/recursive] 

Parameters

Argument

Description

itemspec

Identifies the files or folders to add. For more information about how Team Foundation parses itemspecs to determine which items are within scope, see Command-Line Syntax (Team System).

filetype

Used with the /type option. For more information, see File Types.

Option

Description

/type

Overrides file type matching and adds files to the Team Foundation version control server that uses the specified type. For more information, see File Types.

The file type detection is based on the contents of the first kilobyte of the file.

/lock

Specifies a lock type or removes a lock from an item.

Lock Options:

  • None

    No lock is placed on an item. If a lock is already in place it is removed.

  • Checkin

    Enables an item to be checked out and edited in all workspaces but prevents users from checking in changes to the item outside this /workspace until you explicitly release the check-in lock. If the specified item is locked in any other workspace, the lock operation fails.

  • Checkout

    Prevents users from checking in or checking out any one of the specified items until you explicitly release the lock. If any other users have locked any one of the specified items, or if there are existing pending changes against any item, the lock operation fails.

/noprompt

Suppresses any prompts for input from you.

/recursive

Adds all items in the specified directory and any subdirectories.

Remarks

Before you can add an item to version control, you must set up a local workspace and establish working folder mappings. For more information about getting started, see Walkthrough: Working with Team Foundation Version Control from the Command Line.

Add is a Pending Changes command; it schedules the items that you specify for addition to the Team Foundation version control server pending the completion of a check-in operation from your workspace. To perform a pending change command, your current directory must be mapped to a workspace and the Team Foundation version control server to which it corresponds.

When you use the Add command to add a new item to version control, the item is not actually added to the Team Foundation version control server until you check in your most recent workspace changes. Instead, the item is added to the list of pending changes for the current workspace. To commit the pending addition to the Team Foundation version control server, you can either check in the added file directly, or check in all pending changes in the local workspace. If you are concerned that another user might add a file or folder of the same name as one of your pending additions to the Team Foundation version control server before you have a chance to check in your pending changes, you can include the /lock option with the Checkout parameter to prevent them from doing this. For more information, see How to: Check In Pending Changes.

If you add 314.cs to version control using tf add /teamproject/projects/math/314.cs, each of these folders is considered a pending addition if they do not already exist, until you check in your changes. When you check in the changes, if any of the folders in the specified path (/teamproject, /teamproject/projects, or /teamproject/projects/math) do not already exist in the Team Foundation version control server, Team Foundation creates them for you.

You can use the Add command to establish the initial file structure of a Team Foundation version control server. For more information, see Walkthrough: Working with Team Foundation Version Control from the Command Line.

For more information on how to find the tf command-line utility, see Tf Command-Line Utility Commands.

Examples

The following example adds the files, 314.c and 1256.c to the list of pending changes for the workspace with which the working folder C:\Pi is associated.

c:\pi>tf add 314.cs 1256.c

The following example adds all C# code files (.cs) in the current directory and any subdirectories to the list of pending additions for the current workspace.

c:\projects>tf add *.cs /recursive

The following example adds all files and folders whose names contain "hello" in the current directory and all its subfolders to the list of pending additions for the workspace to which c:\projects maps.

c:\projects>tf add *hello* /recursive

See Also

Tasks

Walkthrough: Working with Team Foundation Version Control from the Command Line

How to: Add Non-Project or Non-Solution Files and Folders to Version Control

How to: Check In Pending Changes

How to: Lock and Unlock Folders or Files

Concepts

Pending Changes

Understanding Lock Types

Other Resources

Tf Command-Line Utility Commands