Is there any way to move classes from one source code file to a new one without losing version control history? We are using TFS.
Thanks.
Is there any way to move classes from one source code file to a new one without losing version control history? We are using TFS.
Thanks.
It's based on which version control system you are working with:
This not possible with TFVC as Marvin Glenn Lacuna also described very clearly above, However you could try the following workaroud:
- Branch FileX to FileA
- Branch FileX to FileB
- Open each file and delete the party you don't want
- Delete FileX
Now you could maintain history on all of the visible lines of pre code through the branch relationship.
For GIT, you could take a look at this question: How does git track source code moved between files?
In TFS, from my experience, the simple answer is no, it stays on the source file and will remain in the source file. It will not be copied to the target file (ctrl+c, ctrl+v
). I believe that's why it is called "file history" and not file section/classes history.
With current TFS version, the default version control is Git. So you could do it by a trick.
Assume that you have two classes ClassA and ClassB in a file named File.ext, your source code is at branch master. The steps should be:
Now you have both files ClsA.ext and ClsB.ext without losing their history from File.ext. An example could be found at my github repository.