Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving files lose history in TFS 2013

I'm using VS2013 Update 4 with TFS 2013 Update 4. In Source Control Explorer, whenever I move a file from one folder to another I can see that the file's history is preserved in the new location. However, that history is gone when I check-in the pending changes. The same thing happens when I try to run "tf move" command. So, how can you move a file in TFS and still keep the file's history?

like image 542
TNV Avatar asked Mar 11 '15 15:03

TNV


People also ask

How do I move files in Azure repository?

In Source Control Explorer, select the item that you want to move, open its shortcut menu, and choose Move. In the Move dialog box, either manually type the destination for the item in the To box, or choose Browse to use the Browse for Folder dialog box. Choose OK.

How do you Rename a file in TFS?

You can use the rename command of the tf command-line utility to move or rename a version-controlled item in your workspace. Use the rename command to move multiple files by specifying wildcard characters.


1 Answers

When a file is renamed correctly, the History is not "Gone", it's associated to the "old name" instead. A rename that is done the right way (tracked as a rename and not as an delete+add) has a drilldown option to view the "older" history:

enter image description here

  • Changeset 81~82 contain the changes to the old name
  • Changeset 83 contains the delete + rename
  • Changeset 84 a new change that was checked in after the rename

When a rename is done outside of the Source Control Explorer (or from a very old version of the Source Control Explorer (e.g. VS 2008)) or outside the Solution Explorer, then the change will be detected as two individual actions, one delete and one add. You can use the "Pending Changes" window to promote these to a rename so that the history is preserved:

enter image description here

On the commandline this can only be accomplished using "tf rename" and "tf move". Using the standard "mv" and "ren" commands will fail to preserve the history.

Below is a further example of using all the different methods and clearly showing that history is preserved by looking at the history of the current file name:

enter image description here

As mentioned in the comments, history is stored in the Team Project that contains the items revision. When branching/moving across projects your history will be spread across these projects. Should you delete a Team project than all history that was accumulated in that project will be lost.

like image 110
jessehouwing Avatar answered Oct 21 '22 20:10

jessehouwing