Last active
December 17, 2015 23:59
-
-
Save jennings/5692976 to your computer and use it in GitHub Desktop.
Tools I'm using to join a few unrelated repositories into one
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/sh | |
# Filters a git branch by moving the entire tree into a subdirectory. | |
# It uses --index-filter; as a result it is very quick but happens to | |
# be very dumb and will move files like .gitignore and .gitattributes | |
# into the subdirectory as well. | |
# | |
# Usage: git-new-subdirectory-filter.sh <subdirName> <branch> | |
# | |
# git-new-subdirectory-filter.sh MySubdirName master..mybranch | |
# git-new-subdirectory-filter.sh MySubdirName --all | |
SUBDIR=$1 | |
BRANCHES=$2 | |
git filter-branch -f --prune-empty --index-filter ' | |
CURRENT_INDEX=$(git write-tree); | |
NEW_TREE_SHA=$(echo "040000 tree $CURRENT_INDEX\t'$SUBDIR'" | git mktree); | |
git read-tree $NEW_TREE_SHA; | |
' -- $BRANCHES |
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/sh | |
# Converts all tags into branches of the form releases/tag-name | |
git fetch --all --tags | |
for tag in $(git tag); do | |
git branch -f refs/releases/$tag $tag | |
git tag -d $tag | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment