TFS 2010: history lost after moving a folder

2019-03-10 21:32发布

问题:

In order to clean up my project structure, I moved a folder into another (new) folder through the TFS Power Tools Shell-Extension (Rename/Move).

After checking the history at the new place, the move is the only entry. (I tried one folder up, down, even on single files in the moved folder.. same result.)

I had also put on some labels on versions of the folder before the move, since there were some important states of the code I wanted to get back to.

So.. what went wrong, and how can I either get the history or at least find out the label names again and check out those versions?

回答1:

Turns out it is pretty easy.

In Visual Studio 2010, go to Tools->Options. There you can find the option to show "deleted" items (roughly in the middle of the dialog box). The old folder got deleted during the move - it will be displayed again after activating that option. (They will be kind of grayed with a red cross.)

Labels seem to have disappeared, though, so I had to go by version.

In the Source Explorer you have the normal operations again - like View History or Get.



回答2:

DISCLAIMER: For reference of everyone that gets here, this answer is not fixing @Andreas problem, just giving some context on why this happens and offering a couple of workarounds.

Seems that losing history when moving folders in TFS 2010 is not a bug, is a "feature". (still happening in TFS2012. From this MSDN link you can read official Microsoft answer:

Thanks for the feedback here. The previous comment about this being by design is correct, and there is an option on the command line. In the UI, history of folders is recursive - always. This is because most of the time, users care about the history of the contents of the folder. Files on the other hand dont have the concept of recursive history - you always see the history for the file itself. Now, from the command line, there is an option to show recursive history (/r) and if you run tf history on a folder without the recursive option, you'll see the changes to the folder itself. This would include changes such as a rename for the folder itself.

  • Workaround to get history once lost: As you can see there, you have a workaround using tf history.
  • Workaround to avoid losing history: If you want to avoid losing history in folders instead of using move feature, you can use TFS Integration tool to migrate code from one folder to other preserving history, migrating from $/TFSCode/FolderA to $/TFSCode/FolderB. It is a little bit overkill but if the history is pretty important for you is much better than looking for it in deleted folders


回答3:

It is true that the folder history is lost, but the individual file history is actually not lost. It is hidden under the little "expand me" arrow at the far left on a file history line. Expand it on the oldest history entry for a file, or anywhere you see it, and you will see history of that individual file also from an old location that no longer exists.



回答4:

At the top of History window you can edit Source location, put the old name and get the full history before it has been moved.

Also, is good to mention that you can get the full history back by moving/rename the branch back to the old location/name.