Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JustCoderdev/acb38b1f925436c0d5631e64ef37b5b2 to your computer and use it in GitHub Desktop.
Save JustCoderdev/acb38b1f925436c0d5631e64ef37b5b2 to your computer and use it in GitHub Desktop.
git-filter-repo

git-filter-repo

Move files and retain history from one repository to another

In source repo

We checkout a branch that we will filter against. We specify the path(s) that we want.

git checkout -b filter-source
git filter-repo --path file1 --path file2 --refs refs/heads/filter-source --force

In target repo

git checkout -b filter-target
git remote add repo-source ../source
git fetch repo-source
git branch branch-source remotes/repo-source/filter-source
git merge branch-source --allow-unrelated-histories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment