Overview
Sometimes, you have to switch the version control system for some reason. In this post, I will cover how to migrate Perforce stream into Git repository. I have confirmed that the method in this post works only in Windows, but you might be able to accomplish the same result with a similar way.
Prerequisites
First of all, you should have Git and Perforce installed. Any latest version would be okay. Plus, you should be able to use their commands through the command prompt. For instance, the commands below should be working:
1 | > p4 -V |
1 | > git -v |
Second, you should have Python installed. The version after 2.7 would be okay. (eg. 2.8 or 3.5) Plus, you should be able to use its commands through the command prompt. For instance, the commands below should be working:
1 | > python -V |
The last one, you have to change your system locale settings if you had written the description of changelist with non-ascii codes. You can enable the option Beta: Use Unicode UTF-8 for worldwide language support
from the depth of Control Panel/All Control Panel Items/Region/Administrative/Change system locale...
.
Unless the option enabled, the commit message from migration result can be seen as untranslatable
if the description was written with non-ascii codes.
With the option enabled, the commit message would be migrated properly just like the image below. So, check your descriptions in Perforce and change the system locale settings.
Migration
Type the command of format python <path of git-p4> clone //<depot>/<stream>/<directory>@all
in prompt. For instance, I can type the command like this:
1 | > python "C:\Program Files\Git\mingw64\libexec\git-core\git-p4" clone //HellLady/mainline/HellLady@all |
Then, all changelists from the //<depot>/<stream>/<directory>
will be migrated into a Git repository.
Postscript
That is all about the migration. 😂 So simple, but it was hard to know because the official document does not cover the usage in Windows. Anyway, I hope this would be helpful for you. Check the official document for more details if you also need other commands. Good luck. 🤞