Last active
December 7, 2021 23:33
-
-
Save postmodern/00b117403fec2a2d7c1fc4f35785cf00 to your computer and use it in GitHub Desktop.
Boilerplate script for automating git-filter-repo
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
#!/usr/bin/env bash | |
set -e | |
shopt -s globstar | |
github_user="FIXME" | |
orig_repo="FIXME" | |
new_repo="FIXME" | |
branch="main" | |
files=( | |
FIXME | |
) | |
args=() | |
for path in "${files[@]}"; do | |
args+=(--path "$path") | |
done | |
git clone "https://github.com/${github_user}/${orig_repo}.git" "$new_repo" | |
cd "$new_repo"/ | |
git checkout "$branch" | |
git filter-repo --force "${args[@]}" --tag-rename '':"${orig_repo}-" | |
git branch -D main || true | |
git branch -m main | |
git tag "$orig_repo" | |
git remote add origin "[email protected]:${github_user}/${new_repo}.git" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and if you want to get a list of every file that ever existed in the git repo, and grep through them for the file/dir names you want to save: