TFS 2010: history lost after moving a folder
Asked Answered
L

4

29

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?

Lorenzen answered 24/12, 2012 at 12:49 Comment(0)
L
21

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.

enter image description here

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

Lorenzen answered 11/1, 2013 at 14:9 Comment(1)
Worked for some files but not all.Eiffel
H
17

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
Heidiheidie answered 25/6, 2013 at 12:7 Comment(4)
Thanks for additional info! One question though: isn't migration simply making a copy (including history)? (I did this some time ago to migrate to a different server - it was not documented too well and generally too complicated for the casual user. In the end it kind of worked, though.)Lorenzen
You're welcome. Migration is a "simply" copy.. but you lose changesets (although old ones are in the description) and dates (all dates are from the moment you perform the migration)Heidiheidie
way too complicated. Just use Subversion or Git and save yourself a mountain of pain.Scientist
This answer is given below by user2570643 and I have tested this.My Scenario: We are manually moving files/folders across folders/projects and this does not result in loss of files history. However, folder history is lost. File history is hidden under the little "expand me" arrow at the far left on a file history line. Expand it to see your history. CheersEntero
C
14

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.

Carat answered 11/7, 2013 at 0:47 Comment(2)
This is the perfect answer. Now I am assured that my files history is safe upon moving files/folders around in TFS, although folder history is lost. That's OK for me. Thank you very much for this!Entero
Please post a screen shoot. I can't find this.Eiffel
L
5

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.

History Window, editable Source Location field

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

Latinist answered 26/7, 2017 at 16:2 Comment(1)
I think this answer should be the accepted answer. After finding that a folder is moved from somewhere else I check the changeset details. Copy pasting original folder to source location is the best way to see history imho.Pompey

© 2022 - 2024 — McMap. All rights reserved.