-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge_other_repos.ps1
More file actions
30 lines (23 loc) · 1021 Bytes
/
merge_other_repos.ps1
File metadata and controls
30 lines (23 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Define repo URLs and base target
$baseRepo = "https://github.com/DefinetlyNotAI/Code_DUMP"
$reposToImport = @(
"https://github.com/USERNAME/PROJECT_NAME",
)
# Step 1: Clone the base repo
git clone $baseRepo Code_DUMP_MERGED
Set-Location Code_DUMP_MERGED
# Step 2: Add each repo as a remote and pull into a subtree preserving full history
foreach ($repo in $reposToImport) {
$repoName = ($repo -split "/")[-1]
Write-Host "`nAdding $repoName as remote..."
git remote add $repoName $repo
Write-Host "Fetching $repoName..."
git fetch $repoName
# Step 3: Merge repo into a subfolder while keeping all commits
Write-Host "Merging $repoName into subfolder $repoName using subtree (full history)..."
git subtree add --prefix=$repoName $repoName main
# Replace 'main' with 'master' if the repo uses 'master'
Write-Host "Removing remote $repoName..."
git remote remove $repoName
}
Write-Host "`nAll repositories imported into subfolders with full commit history preserved."