-
clone this repository
git clone https://gist.github.com/wookietreiber/290e909a39cf7a02c8e89290e6fc4fed git-extract
-
make
git-extract
script available to your shellmkdir -p ~/bin cp git-extract/git-extract.sh ~/bin/git-extract chmod +x ~/bin/git-extract
point your PATH to
~/bin
(default in most distros)
-
create a fresh clone of the repository
git clone repo
-
run git extract on the files you want
git extract file.a file.b file.c
this rewrites the complete history and keeps only the commits that changes the files you specified
-
clean up old git references
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
-
(optional) rewrite commit messages
git rebase -i --root
replace pick with reword because in interactive rebase you will see only the first line of the commit message. if you don't want to change the message just close the editor without changing the text.
-
remove remote
git remote remove origin
-
create new remote (use GitHub, GitLab or whatever)
-
add new remote
git remote add origin repo
-
push to new remote
git push -u origin repo