Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019 | TFS 2018
Visual Studio 2019 | Visual Studio 2022
The Team Foundation Version Control (TFVC)
difference command compares, and if possible displays, differences between two files, files in two folders, or a shelveset and a local or a server file.
To use the
difference command, you must have the Read permission for all specified items set to Allow. For more information, see Default TFVC permissions.
tf diff[erence] itemspec [/version:versionspec] [/type:filetype]
[/format:format [/ignorespace] [/ignoreeol] [/ignorecase] [/recursive]
tf diff[erence] itemspec itemspec2 [/type:filetype] [/format: format]
[/ignorespace] [/ignoreeol] [/ignorecase] [/recursive] [/options] [/noprompt][/login:username,[password]]
tf diff[erence] [/shelveset:shelvesetname[;shelvesetowner]]
[/format: format] [/ignorespace] [/ignoreeol] [/ignorecase]
[/recursive] [/options] [/noprompt][/login:username,[password]]
tf diff[erence] /configure
Required. Specifies the item to be compared. If no version or path is specified, the current workspace version is assumed. Accepts both local and Azure DevOps server paths.
For more information about how TFVC parses the
itemspec to determine which items are within scope, see Use Team Foundation version control commands.
difference command doesn't support wildcard characters.
This parameter can't be combined with the
Optional. The item to which the
itemspec is to be compared. If you don't provide a second
itemspec, the latest Azure DevOps server version of the item is used.
Provides a value for the
/type option. You can specify
text and a codepage number or the friendly name for a codepage.
Used with the
/format option to specify an output format of one of the following types:
These output formats are explained in the Remarks section.
The user-provided value for the
/version option. For more information about how TFVC parses a version specification to determine which items are within its scope, see Use Team Foundation version control commands.
Identifies the owner of the shelveset by user name. If a value for this parameter isn't provided, the current user is assumed.
Specifies the name of a shelveset. You can create more than one shelveset with the same name on the server that is running TFVC as long as a different user owns each shelveset.
Specifies the name of a folder or file in the shelveset to compare to the base shelveset version.
Provides a value to the
/login option. You can specify a username value as either
Overrides any detected encodings and uses the specified encoding to present the files to the differencing engine.
Specifies the version of the file or folder to compare. By default, TFVC uses the workspace version if you don't provide a
Instead of using the
/version flag, you can specify versions by appending a semicolon and version specifier to the end of each file name.
Specifies an output format specified by the
Doesn't highlight whitespace differences between the compared files.
Ignores differences between the new line characters in two files or file versions.
/ignoreeol works differently from
ignorespace, which treats eight spaces identically to one. However, if you use the
/ignoreeol option and File A has two new line characters between unchanged areas of text, and File B has one, the result displays as a difference. If both files have only one new line, but File A uses
\r\n as a new line and File B uses
/ignoreeol option would ignore that as a difference.
Doesn't highlight differences in letter casing between the compared files.
Compares the differences between the current folder and all its subfolders.
Specifies a shelveset to compare to the Azure DevOps server version upon which the shelveset is based.
This option can't be combined with an
itemspec argument. To compare individual shelveset items, you can provide a
Suppresses any dialog boxes that would otherwise be displayed during the completion of this operation.
Invokes the Configure User Tools dialog box from the Visual Studio user interface. For more information, see Associate a file type with a difference tool.
Specifies the user name and password to authenticate the user with TFVC.
You can type
tf diff or
tf difference at the command line to run this command.
You can use the
difference command to compare and if possible display differences between:
Two different files or two versions of the same file.
One or more of the items in a folder.
One, some, or all the items in a shelveset on the Azure DevOps server.
You can use the
difference command to compare both versioned and non-versioned files.
TFVC categorizes all files by type. Text files can be merged and compared, side by side and line by line, as long as both files have the same encoding. If you want to compare two files whose encodings aren't the same, you can temporarily mask or override the encoding property for a file by using the
Binary files can be compared but can't be merged. When you pass one or more binary files to the
difference command, TFVC indicates whether differences exist between it and the item to which it's being compared. For more information about how TFVC differentiates between and treats files of different types, see Managing file types.
If you specify two file names, the two files are compared. Instead of using the /version flag, you can specify versions by appending a semicolon and version specifier to the end of each file name.
If you pass only one
itemspec to the difference command:
If you don't provide a
versionspec, your current workspace version of the item is compared to the base workspace version, by default. For example,
tf difference header.hcompares the current version of header.h to the version upon which header.h is based.
If you include a
itemspec, such as
tf difference header.h;LBeta1, TFVC compares that version to your current workspace version on disk.
If you specify a range of versions such as
/version:C1~C4, the versions of the file at the two endpoints of the range are compared.
For more information on how to use the
tf command-line utility, see Use Team Foundation version control commands.
Output format types
format parameter, used with the
/format option, specifies many different output formats. The following output types are available:
Visualformat type opens an external difference application. By default, diffmerge.exe is launched.
Briefformat prints whether the files being compared differ.
Contextformat provides lines of context for the differences in the files. This format is derived from the UNIX-based
diff -coutput format.
RCSformat is similar to
/format:unix, except context lines aren't supplied. No special handing for a missing end of line marker at the end of the file is provided.
SSis the default difference output format for Visual SourceSafe. For more information, see Diff (command line).
SS_SideBySideis the default side-by-side output format for Visual SourceSafe.
SS_Unixis similar to the
/format:unixoutput format, but
/format:ss_unixincludes context lines and
Unifiedformat is derived from the UNIX-based
diff -uoutput format.
/format:contextrepeats identical context lines between the difference strings, but
Unifiedformat produces a new unified difference string (
@@ ... @@) line only when the distance to the next difference string is larger than the number of context lines.
Unixoutput type is derived from the UNIX-based
diffcommand output format.
Unixoutput format is constructed in the following way:
<metadataline> "< " line prefix for lines from the first file "---" line "> " line prefix for lines from the second file <metadataline> can be one of these possibilities: #a#,# -- add lines from line # in file1 into file2 at lines #-># #,#d# -- delete lines from line # -> # in file 1 from file2 at line # #,#c#,# -- change lines from line # -> # in file1 into the lines in file2 at line # -> # # signs separated by commas indicate a line range. # signs before the character indicate line numbers in the first file. # signs after the character indicate line numbers in the second file. /// No end of line marker at the end of the file: /// \ No newline at end of file
The following example displays the differences between the local version of 314.cs and the workspace version of 314.cs that's the version of the file that was checked out from the Azure DevOps server.
c:\projects>tf difference 314.cs
The following example displays all files that have been changed in the src folder, but doesn't display files that have been changed in subfolders of src.
c:\projects>tf difference src /format:visual
The following example displays the differences between changeset 3 and changeset 8 of 1254.cs.
c:\projects>tf difference /version:C3~C8 1254.cs
The following examples display the differences between the version of 314.cs that belong to the label
release and the version that belongs to changeset 3200.
c:\projects>tf difference 314.cs;Lrelease 314.cs;C3200
c:\projects>tf difference 314.cs;Lrelease~C3200
The following example displays the difference between the versions of e271.cs that a user named Pat shelved in shelveset
PeerCodeReview8 and the base shelveset version that they based their changes on. The output also shows the types of changes pending against
e271.cs when the user shelved.
c:\projects> tf difference /shelveset:PeerCodeReview8;Pat e271.cs
The following example displays the differences between all files in the
PeerCodeReview2 shelveset and the base shelveset version of those files.
c:\projects> tf difference /shelveset:PeerCodeReview2