Skip to content

Instantly share code, notes, and snippets.

@cowboy-bebug
Created October 15, 2019 22:12
Show Gist options
  • Save cowboy-bebug/c82ae33c075441a42a236e160d4f6798 to your computer and use it in GitHub Desktop.
Save cowboy-bebug/c82ae33c075441a42a236e160d4f6798 to your computer and use it in GitHub Desktop.
moving directories from one repo to another
# clone repos
mkdir move-repo && cd move-repo/
git clone <repo-src>
git clone <repo-dst>
# prepare source
cd repo-src
#git checkout <branch-in-repo-src> # optional
#git remote rm origin # optional
git filter-branch --subdirectory-filter <directory-to-move> -- --all
mkdir new-dir/
git mv -k * new-dir/
git commit -m "collect data and history to move"
# prepare destination
cd ../repo-dst
git remote add repo-src ../repo-src/
git fetch repo-src
git branch repo-src remotes/repo-src/master
git merge repo-src --allow-unrelated-histories
# either
git push origin master
# or
git checkout -b <branch-name>
git rebase origin/master
git push & pull request :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment