Created
April 26, 2019 19:00
-
-
Save beck/e7b9d25389c953dbefb4bf712c52c247 to your computer and use it in GitHub Desktop.
git filter folder
This file contains 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 -eux | |
# Use this script to prune away everything but `foo/bar/somedir`, resulting with only `somedir` | |
# in the root. Using `--subdirectory-filter` is undesireable because it hoists all the contents | |
# of `somedir` into the root. | |
mkdir -p __github-migrate__ | |
mvplz="if [ -d $1 ]; then mv $1 __github-migrate__/; fi;" | |
git filter-branch -f --tree-filter "$mvplz" HEAD | |
git filter-branch -f --subdirectory-filter __github-migrate__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment