Merge Command

The merge command applies changes from one branch into another.

Note

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

Required Permissions

To use the merge command, you must have the Check out permission set to Allow for the workspace folder that contains the destination or target for the merge operation. You must also have the Read permission set to Allow for the workspace folder that contains the source. For more information, see Team Foundation Server Permissions.

tf merge [/recursive] [/force] [/candidate] [/discard] 
[/version:versionspec] [/lock:none|checkin|checkout] [/preview] 
[/baseless] [/nosummary] [/noimplicitbaseless] source destination

Parameters

Argument

Description

versionspec

Specifies a value such as C2 for the /version option. For more information about how Team Foundation parses a version specification to determine which items are within its scope, see Command-Line Syntax (Team System).

source

Specifies the file or folder to act as the source of the merge.

Destination

Specifies the file or folder to act as the destination, or target of the merge.

Option

Description

/recursive

Matches the source item specification in the current directory and any subfolders.

/force

Ignores the merge history and merges the specified changes from the source into the destination, even if some or all these changes have been merged before.

/candidate

Prints a list of all changesets in the source that have not yet been merged into the destination. The list should include the changeset ID that has not been merged and other basic information about that changeset.

/discard

Does not perform the merge operation, but updates the merge history to track that the merge occurred. This discards a changeset from being used for a particular merge.

/version

For a selective merge, this option specifies the range that should be merged into the destination or target. For a catch-up merge, this parameter specifies the version before which all un-merged changes should be merged.

For a selective merge, the version range represents the starting and end points of the set of changes to be merged. For example, if you try to merge version 4~6, the changesets 4, 5, and 6 are merged.

/lock

Specifies a lock type or removes a lock from an item. For more information, see Understanding Lock Types.

Lock Options:

  • None

    No lock is put on an item and removes any existing lock from an item.

  • Checkin

    Other users can check out the specified items but they cannot check in revisions to locked files until you release the lock by performing a check-in. If any other users have locked any one of the specified items, 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.

/preview

Shows a preview of the merge.

/baseless

Performs a merge without a base version. That is, allows the user to merge files and folders that do not have a merge relationship. After a baseless merge, a merge relationship exists and future merges do not have to be baseless.

/nosummary

Omits summary of errors and warnings when doing this requires more than 10 lines of output.

/noimplicitbaseless

Specifies that Team Foundation will not perform an implicit baseless merge between two items that have the same relative name in two unrelated version-control trees.

/noprompt

Suppresses any prompts for input from you.

Remarks

You can use the merge command of the tf command-line utility to apply changes in an existing source branch to an existing target branch. You can merge an individual revision or a complete changeset to the target branch. You can merge changes from the source to the target branch or from the target to the source branch.

The merge command also lets you query for changes in a source branch which have not been migrated to the target branch. Additionally, it lets you indicate that certain changes will never be merged from the source to the target and should no longer be displayed as candidates for a merge operation.

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

Baseless Merge

Use baseless merge to merge items that are not directly branched from each other. To perform a baseless merge, you must use the tfmerge command. When you perform a baseless merge, Team Foundation does not have any information about the relationship of the files in the branches. In a baseless merge, you must perform manual conflict resolutions. After you have performed the baseless merge and resolved any conflicts, Team Foundation records the merge history and establishes a relationship between the folders and files.

When you run tfmerge, Team Foundation performs an implicit baseless merge between items that have the same relative name in two previously related version-controlled trees. For example, you might want to merge the related branches SRC and TGT. Both branches contain an unrelated file that is named a.txt. When you run tf merge, Team Foundation establishes a relationship between the two a.txt files if the two files are the same, if FIPS-compliant encryption is disabled, and if the source file is not related to any other file in the target.

If you run tf merge with the /noimplicitbaseless option set, when Team Foundation tries to merge the two branches, the two a.txt files will create a namespace conflict when you try to check in the changes. To resolve the conflict, you must rename one of the files.

Examples

The following example merges changes from MyFile_beta1 that have not been merged into MyFile_RTM.

c:\projects>tf merge MyFile_beta1 MyFile_RTM

The following example merges only the changes from changeset 137 into branch2.

c:\projects>tf merge /version:C137~C137 branch1 branch2 /recursive

The following example merges all of the changesets from the first changeset through to and including changeset 137, from branch1.

c:\projects>tf merge /version:C137 branch1 branch2 /recursive

The following example merges all of the changes from changeset 100 through to and including changeset 137.

c:\projects>tf merge /version:C100~137 branch1 branch2 /recursive

The following example prints a list of the changesets in branch1 that have not been merged into branch2.

c:\projects>tf merge /candidate branch1 branch2 /recursive

The following example prints a list of changesets in branch2 that have not been merged back into branch1.

c:\projects>tf merge /candidate branch2 branch1 /recursive

The following example discards changeset 137 as a candidate for merging into branch2.

c:\projects>tf merge /discard /version:C137 branch1 branch2 /recursive

See Also

Tasks

Walkthrough: Advanced Functionality of Version Control

How to: Resolve Conflicts Between Two Files

Concepts

Understanding Branching

Reference

Command-Line Syntax (Team System)

Branch Command

Merges Command

Other Resources

Tf Command-Line Utility Commands