Senior LevelGit & GitHub
How do you use git subtree split to extract a sub-directory into a standalone repository?
❓ Interview Prompt: Explain git subtree split -P <prefix>, extracting subfolder commit history, and publishing monorepo packages as independent repositories.
git subtree split -P <prefix> -b <branch> extracts the complete historical commit lineage of a specific subdirectory into a new independent branch for publishing as a standalone repository.
Code Implementation Example
bash
git subtree split -P packages/ui-components -b standalone-ui
git push git@github.com:org/ui-components.git standalone-ui:main💡Extracting subfolder commit history into a standalone repository using git subtree split.
🎯 Interview Key Takeaway
Use git subtree split -P <prefix> -b <branch> to extract a subfolder's commit history into an independent repository.
#git subtree split#Monorepo Extract#Senior
Back to all Git & GitHub Questions→