TF Merge Command

4.9k Views Asked by At

I use the following command to merge a single changeset from Source to target branch:

result = BatchCommand(@"tf merge /version:" + chgnumber + "~" + chgnumber + @" """ + Source + @""" """ + Target + @""" /recursive /login:" + UID + "," + PWD + "", SourceTar[2]);

BatchCommand is another method which executes the command in cmd in my workspace SourceTar[2]. in some cases I get the error where I need to overwrite files. How can I do this automatically (Overwrite files).

Should I use /force for that? It definetly will resolve that overwrite conflict but will it also resolve other conflict(I don't want that).

I only want to overwrite files if that error occurs, other conflicts are resolved programmatically. Any suggestion would be helpful;

1

There are 1 best solutions below

1
Vicky - MSFT On

You need to work with tf resolve command to resolve conflicts. Your commands can be the similar to:

tf merge $/TeamProjectRoot/Branches/Source $/TeamProjectRoot/Branches/Target
tf resolve $/TeamProjectRoot/Branches/Target /r /i /auto:TakeTheirs

/auto:TakeTheirs option accepts the changes from the source of the merge and overwrites the changes in the target.
/auto:KeepYours option discards the changes from the source of the merge and leaves the target unchanged.