Import git history
Need to import the git history of one repository into another due to consolidation of several separate microservices into a single vertical slice service.
Example
I have a repository called infra
and I want to import the history of commits into the new current folder as it holds my consolidated repository. Need to get the git content by applying git ls-tree
to each file element is the goal.
Bash
git ls-tree --name-only HEAD | grep -v '^infra$' | xargs -I {} git mv {} infra/
PowerShell
Unfortunately there is no grep or xargs to help me out here and the unix approach of using .hidden
for files and folders means git history can get imported so need to skip those files hence the need for the ^$folder$|^\." -notMatch
$folder = "infra"; git ls-tree --name-only HEAD | Select-String -pattern "^$folder$|^\." -notMatch | ForEach-Object { Move-Item $_ -Destination #$folder/$_"