-
In your current repository, create a new orphan branch, containing the contents of the first commit you want to copy:
$ git checkout --orphan -b tmpbranch <hash_of_first_commit> $ git commit -a -m 'first commit'
-
Cherry-pick the rest of the commits you want:
$ git cherry-pick <hash_of_first_commit>..mybranch
-
Push this new orphaned branch to your new repository, as the new master branch:
$ git push <URL_of_new_repo> refs/heads/tmpbranch:refs/heads/master
-
Delete the tmpbranch so garbage collection will eventually clean up for you:
$ git checkout mybranch $ git branch -D tmpbranch
Last active
October 14, 2023 08:07
-
-
Save trepichio/00fb7fa59b62cc393c19c5b226961ca1 to your computer and use it in GitHub Desktop.
Transfer a partial history from a git branch to a new repository
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Must be
(the
-b
isn't needed and doesn't work).