Last active
August 29, 2015 14:13
-
-
Save scari/674092e99ca8202c8a71 to your computer and use it in GitHub Desktop.
Import existing git repo into sub directory of another git repo.
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 | |
# NOTE: | |
# You couldn't track original branch (which would imported under current repo) history from current repo. | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: $0 prefix url" | |
exit 0 | |
fi | |
NAME=$1 | |
URL=$2 | |
PREFIX=${NAME} | |
TEMP_BRANCH=${NAME}_branch | |
git remote add $NAME $URL | |
git fetch $NAME | |
git checkout -b ${TEMP_BRANCH} ${NAME}/master | |
git checkout master | |
git read-tree --prefix=${PREFIX}/ -u ${TEMP_BRANCH} | |
# | |
echo "'${NAME}/master' from '${URL}' is now under '${PREFIX}' in curreunt repo." | |
echo "You can commit your changes now." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment