This post is not about merging an existing item to an non-existing one, which will be a (merge, branch) change. This post is about merging items that already exist but they were not branched. One of our customers had this problem, he had three branches: A –> B –> C and he needed to port some changes from A to C. Unfortunately, his team copied the files from A and added them to C instead of merging the changes from A to B then from B to C. So, he ended up with the same contents but without the branch or the merge relationship. The solution for this problem depends on what version you’re running. If you are running TFS 2005, then you need to merge A –> B –> C and this will result in Filename Collision conflicts, then you’ll need to undo the conflicting changes and do a baseless merge for each item. If you have many items, you may want to use a FOR loop that reads the inputs from text files:
FOR /F %i IN (undo.txt) DO tf undo /i %i
FOR /F “tokens=*” %i IN (merge.txt) DO tf merge /i /baseless %i
If you’re running TFS 2008 or later, we do the baseless merge for you implicitly.
Note that if the merge relationship is already established between source and target items, you wouldn’t want to use /baseless because it implies /force. Baseless is useful when you want to merge without referring to a base version, and it establishes a merge relationship between items that don’t have it already so that future merges don’t need the /baseless option. Baseless merge implies /force because it means that there’s no merge history and no base version.