All checks were successful
Build and Deploy Quartz / build-and-deploy (push) Has been skipped
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
import { execSync } from "child_process"
|
|
|
|
function run(cmd) {
|
|
try {
|
|
console.log(`> ${cmd}`)
|
|
execSync(cmd, { stdio: "inherit" })
|
|
} catch (e) {
|
|
console.error(`Error running: ${cmd}`)
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
function main() {
|
|
// Step 1: Create orphan branch
|
|
run("git checkout --orphan temp-branch")
|
|
|
|
// Step 2: Add all files
|
|
run("git add .")
|
|
|
|
// Step 3: Commit
|
|
run('git commit -m "init: init commit"')
|
|
|
|
// Step 4: Rename current main to old
|
|
run("git branch -m main old")
|
|
|
|
// Step 5: Rename temp-branch to main
|
|
run("git branch -m temp-branch main")
|
|
|
|
// Step 6: Checkout main
|
|
run("git checkout main")
|
|
|
|
// Step 7: Set upstream for main branch to origin/main
|
|
run("git branch --set-upstream-to=origin/main main")
|
|
|
|
// Step 8: Set upstream for old branch to origin/old if it exists locally
|
|
try {
|
|
run("git show-ref --verify --quiet refs/heads/old")
|
|
run("git branch --set-upstream-to=origin/old old")
|
|
console.log("Upstream for 'old' branch set to origin/old.")
|
|
} catch (e) {
|
|
console.log("Local 'old' branch does not exist, skipping upstream setup.")
|
|
}
|
|
|
|
console.log("Git history cleared and remote branches updated.")
|
|
}
|
|
|
|
main()
|