Skip to content

Instantly share code, notes, and snippets.

@kjivan
Created December 28, 2021 21:38
Show Gist options
  • Save kjivan/5cab1803df5042e91ac7c3ba3b7d2c15 to your computer and use it in GitHub Desktop.
Save kjivan/5cab1803df5042e91ac7c3ba3b7d2c15 to your computer and use it in GitHub Desktop.

Git Reference

Repo Reorging

Create new repo from a folder

git clone <base repo>
cd <base repo>
git filter-repo --path folder/
git remote set-url origin <new repo>
git push -u origin main

Add repo as a folder

git subtree add -P <folder> <repo> <branch>

Delete history

Delete history for a path

git filter-repo --path <delete> --path <delete> --invert-paths

Keep history only for a path

git filter-repo --path <keep> --path <keep>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment