We need to import Git Repository from one network to another. For security reasions it must pass as text files, that represents readable version of the inner files (all the blobs of the repository, or at least all the diffs between tow blobs). Creating tar from the .git
dir isn't good (not readable for the security scans), nor git bundle
format.
The promisable candidate is patch files (the security scan know to handle binaries in base64 of patch). It work perfect for linear repo, but we need merging commits as well. We thought about script that'll do in the source: git log -p -m --parents --first-parent > file
, and in the dest will parse that file and will:
- Apply it commit by commit with
git am
- At each branching (second child of one parent) will create branch (with the name
branch<hash-of-first-commit>
) - for each merge will do:
git merge <branch-name> --no-commit -s ours
, thangit apply
of the first-parent diff, thangit commit ...
After that we just need to rename the branches to the real names, and done. I don't see flaws, but it's not yet implemented.
Questions:
- Is there existing, working solution (script, tool) for this purpose?
- If not - is ther any flaws in the process I described that will make it to not reflect exactly the commits with the correct connections between them (We don't have to keep the original commit hashes)?