Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save matham/ca18cd247cbd7692db45b3b8ca97fe2c to your computer and use it in GitHub Desktop.
Save matham/ca18cd247cbd7692db45b3b8ca97fe2c to your computer and use it in GitHub Desktop.
from https://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/
git clone <git repository A url>
cd <git repository A directory>
git remote rm origin
git filter-branch --subdirectory-filter <directory 1> -- --all
git filter-branch --index-filter '
git read-tree --empty
git reset $GIT_COMMIT -- cplcom/painter.py
' -- --all -- cplcom/painter.py
mkdir <directory 1>
mv * <directory 1>
git add .
git commit
git clone <git repository B url>
cd <git repository B directory>
git remote add repo-A-branch <git repository A directory>
git pull repo-A-branch master --allow-unrelated-histories
git remote rm repo-A-branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment