Merging Development Branch to Main: There were no changes to merge

aidonsnous picture aidonsnous · Dec 21, 2014 · Viewed 13.7k times · Source

My main branch has some files that have different codes from the same file of development branch. The development branch is the one that has the correct version of these files but when I am trying to merge it to main branch(target); I am getting a message saying

There was no changes to merge

How can I resolve that problem so that the main branch has the correct version of those files?

Answer

jessehouwing picture jessehouwing · Dec 21, 2014

When merging files TFS doesn't just look at the differences between the two branches, but it also keeps track of whether you've ignored these changes in a previous merge attempt. When merging TFS offers you 3 options when there are conflicts:

  1. Merge
  2. Keep Source
  3. Keep Target

When you pick Keep target or when you manually merge and deselect certain changes, TFS will mark these changes as "resolved" and will not offer them again when you try to merge in the future. This is called a "merge credit".

You can also create these issues using the commandline when using tf merge /discard which will tell TFS to ignore the changes in those files/changesets when considering merges.

There are two ways to force TFS to reconsider these changes:

  1. Use force merge. On the commandline you can initiate a merge in which TFS will temporarily ignore it's records and will offer you every different file for merging. This can be a lot of work, but once done your merge history will be back in shape. To issue a force merge run tf merge $/Source/Folder/File $/Target/Folder/File /force This will almost certainly raise a merge conflict which you can resolve to get the right changes in the target branch.

  2. Undo the previous merge using Rollback. If you've recently done the merge in which changesets have been discarded. Find it in the history, rightclick the changeset and pick Rollback and check in the code that has been undone. This will actually remove all of the changes in that changeset and will reset the "merge credits". Once this has been done you can redo the merge and do it right this time. This can also be done from the command line using tf rollback