Catalog · How the catalog works
ProjectMigrator
Windows GUI tool to help creating bash scripts to run mass git rm/mv to reorganize a source tree
- ★ 1 on GitHub
Anyone may press Interesting, signed in or not. It helps others find this project.
README
Project Migrator
This tools ease migration of a project files from an original source tree to a new one.
The aim is to migrate files using git rm [-r] <file_or_dir> <file_or_dir> and git mv <file_or_dir> <file_or_dir> to force git to keep files history.
How to ?
Prerequisites:
- a legacy project with a mess of files. Say that original Repo resides within the
legacyrepository - a fresh new git repository where you will cleanup all that mess, say you will call it
future - tons of motivation to refactor and cleanup this project and make is as fresh as a daisy
Steps:
- Prepare a new, empty repository for your project, move files, reorganize, make it as perfect as you can. Try avoid renaming files at this step, just move them around and change build/project files to match new locations. Make sure everything build and that tests passes.
The obvious way from here is to delete all files from legacy working tree and to copy them from the futureworking tree. Then let git sort out renames and deletes. Sometimes, it works. So you can stop this tutorial here, you just saved several hours of painful job.
If you're still here that means that git was not able to sort out renames.
The goal here is to create a bash script (if you're on Windows you will be able to run it by using the "Git Bash Here" console from GitForWindows) to move and delete files or directories.
- Reset the
legacyrepository (git reset --hard) and make surefuturerepository is clean (you can create a clean clone next to thefutureworking dir by usinggit clone ../future future-empty) - Start
ProjectMigrator - In the "Source" column, point to the
legacyrepository. Click therefreshbutton to load its files and folders hierarchy. - In the "Destination" column, point to the
furure(orfuture-empty) repository. Click therefreshbutton to load its file and folders hierarchy. - Click the
Create Destination Folders Hierarchybutton to addmkdirlines to the output script. - Then, the painful job... move files by drag-and-dropping files and folders from
Sourcetree toDestinationtree. - You can mark a source file or folder as deleted by right clicking on it.
- The script panel updates in real time. But remember that this script is a simple text file, you can change, correct, move, remove or add lines manually.
- You can run a simple check to make sure all files exists by clinking the
Verify Scriptbutton above the script (onlygit rm [-r]andgit mvcommands are checked) - There is a
Save Current Statebutton to save the current state of bothSourceandDestinationtrees in a binary files that resides within user%appdata%(for me it'sC:\Users\zedalaye\AppData\Roaming\ProjectMigrator\state.bin), the script is also saved at the same place in ascript.shtext file. - When all files have been mapped from
SourcetoDestinationand you are happy with your job, you can try to run the script :- Go to the working dir of
legacyrepository usingGit Bash HerefromGitForWindows - Run
$ bash /c/Users/<you>/AppData/Roaming/ProjectMigrator/script.shyou may have to modify the script to run extra cleanup actions like removing empty repositories. - It everything worked as expected
git statusshould report onlyrenamed...ordeleted...files. - When you are happy, commit.
- Delete all files from
legacyworking directory - Copy all files and folders from
future(orfuture-empty) repository - Commit
- You're done.
- Go to the working dir of
Building ProjectMigrator
You will need Delphi 10.3.3 (but it may work with previous versions too) I suggest that you try with the free Delphi Starter Edition
Dependencies: the Project JEDI JCL and JVCL libraries and the VirtualTreeView library must be installed.

