Created
June 19, 2024 14:47
-
-
Save zephraph/692f4adb55d326841146c8b76d36e080 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
FROM=$1 | |
TO=$2 | |
NEW_NAME=${3:-$FROM} | |
cd "$FROM" | |
FROM=$(pwd) | |
# Uses https://github.com/newren/git-filter-repo | |
git filter-repo --to-subdirectory-filter "$NEW_NAME/" | |
cd "../$TO" | |
git remote add "$NEW_NAME" "$FROM" | |
git fetch "$NEW_NAME" | |
git checkout master | |
git merge --allow-unrelated-histories "$NEW_NAME"/main | |
git remote remove "$NEW_NAME" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment