Checking in files

*Prerequisite: This task assumes you have completed the steps outlined in the section Before you Begin, and that you have files pending a change in your TFS workspace.

Files checked out for editing, or files pending changes such as add, delete, rename, shelve, and branch can be checked in to a TFS Source Control repository. A check-in means you are committing changes made in your workspace to the the TFS source control repository. When you check in pending changes, TFS creates a new changeset in the server. Teammates connected to the same project can then access your changes by performing a Get Latest operation.

There are two methods for checking in files (or committing pending changes) to TFS source control. You can check in files from the Team menu by right-clicking the item(s), or you can check in from the Teamprise Pending Changes - Source Files view.

Method 1

To check in files using the Team menu:

  1. Right-click on a file or folder you want to check in. (To check in multiple files, hold down the Ctrl key while selecting.) From the popup menu select Check In Pending Changes...

  2. In the Check In - Source Files dialog, deselect any file you do not wish to check in to the repository by unchecking the check box. Enter a comment in the comments section. If your check-in resolves a bug logged in the Work Items repository, select the work item tab to associate the bug with the changeset. For more information see Associating Work Items with Changesets. Click the check-in icon to commit files to source control.

    Note: Whenever you check in a file, it's a good practice to include comments in the comment section of the Check In - Source Files window. Comments appear in the Teamprise History view and can be helpful in retrieving a previous version of a file.

  3. If your Team project is configured to require Check-in Notes, an error message will prompt you to append a Check-in Note when you attempt to check in files from a Pending Changes view. Click OK.

  4. Select the Check-in Notes tab. Enter any required information and click the Check In button to add all selected files. Files successfully checked in will no longer appear in the Check In - Source Files window.
    Note:
    Check-In Notes are customized in TFS. The image below is an example of one customization.

Method 2

All files pending a change such as edit, add, delete, shelve, branch, or rename are types of pending changes and so appear in the Pending Changes - Source Files view. To check in (or commit changes) from the Pending Changes - Source Files view:

  1. By default all files in the Pending Changes - Source Files view contain a check mark in the check box. If your check-in resolves a bug or satisfies a task logged in the Work Items repository, select the work item tab to associate a work item with the changeset. For more information see Associating Work Items with Changesets. Click the check-in icon to commit files to source control.

    Tip: If you check in a file and the file still appears in the Pending Changes - Source Files view, click the Refresh icon to the right of the check-in icon. This should clear any pending check-ins from the Source Files list. If a file still appears after checking in and refreshing, select the Console tab to view messages related to your check-in attempts.

    When you check in a file, you are submitting a new changeset to source control. The Console returns the following message when you have successfully checked-in a file or files:

    Changeset [#] successfully checked in.

    If you are unable to check in a file it may be that a newer version of the file exists on the server. See Resolving Conflicts for instructions on resolving these types of conflicts.

Which method is best?

If you have dozens of files checked out and you only want to check in a single file, it's best to use Method 1 which invokes the Source Files dialog with only that file selected. Otherwise, using Method 2, you would have to manually uncheck each file you do not want to check in.

Similarly, if you want to check in all but one of your pending changes Method 2 is the better method. It does not require selecting files across directories, since all checked out files appear in the Pending Changes / Source Files view. In this view you can simply uncheck the one file you do not wish to check in at this time.


Related Tasks:

Associating work items with changesets
Understanding the Check-out and Check-in Concepts in Source Control Systems