Skip to content

Instantly share code, notes, and snippets.

@iangreenleaf
Created May 12, 2014 18:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iangreenleaf/984bc6765d2a4dc49862 to your computer and use it in GitHub Desktop.
Save iangreenleaf/984bc6765d2a4dc49862 to your computer and use it in GitHub Desktop.
Import seperate git repo as subdirectory
export target=my_dir
git remote add "$target" file:////path/to/original/repo
git fetch "$target"
git co -b "$target" "$target/master"
# Probably breaks on whitespace, sorry dawg.
git filter-branch -f --tree-filter "mkdir -p \"$target\"; git ls-tree \$GIT_COMMIT --name-only | xargs --no-run-if-empty mv -t $target" "$target"
git co master
git merge "$target"
git remote remove "$target"
git br -d "$target"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment