Skip to content

Instantly share code, notes, and snippets.

@justinmassiot
Last active December 11, 2023 15:28
Show Gist options
  • Save justinmassiot/79303df733c286f831f968d35fe1a443 to your computer and use it in GitHub Desktop.
Save justinmassiot/79303df733c286f831f968d35fe1a443 to your computer and use it in GitHub Desktop.
Instructions to export a subdirectory to a new git repository and keep the history
# Source: https://ao.gl/how-to-split-a-subdirectory-to-a-new-git-repository-and-keep-the-history/
git filter-branch --prune-empty --subdirectory-filter relative/path/to/subdirectory your_current_branch_name
git remote set-url origin https://github.com/subfolder/your_new_sub_repo.git
git push -u origin your_current_branch_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment