Last active
March 22, 2020 07:11
-
-
Save alvis/5398f9f81db7130cbfd7e26b3b210da8 to your computer and use it in GitHub Desktop.
git: move a folder with all histories rewritten
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/sh | |
FROM=$1 | |
TO=$2 | |
TEMP=$(mktemp -d) | |
echo Moving "$FROM" to "$TO" | |
git filter-branch -f --tree-filter "if [[ -e '$FROM' ]]; then mkdir -p "$(dirname $TO)"; mv '$FROM/' '$TEMP'; mv '$TEMP/' '$TO/'; fi" --tag-name-filter cat --prune-empty -- --all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment