Skip to content

Instantly share code, notes, and snippets.

@IrakliJani
Created April 15, 2019 03:54
Show Gist options
  • Save IrakliJani/2922d5f5c8242caa0220ed1d9a4dba3d to your computer and use it in GitHub Desktop.
Save IrakliJani/2922d5f5c8242caa0220ed1d9a4dba3d to your computer and use it in GitHub Desktop.
Git code move from repo A to repo B with history
git clone [repo-A-url] [repo-A-name]
cd [repo-A-name]
git checkout [branch-in-repo-A]
git remote rm origin
git filter-branch --subdirectory-filter [directory-to-move] -- --all
mkdir [folder-to-move]
mv * [folder-to-move] # mind the hidden files
git add --all
git commit
cd [repo-B-path]
git checkout -b [branch-name]
git remote add [move-origin] [repo-A-path]
git pull [move-origin] [branch-in-repo-A]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment