This command will create a branch with no parent (no commit history) on a repo.
git checkout --orphan <new-branch>
Manage folders linked to others branches of your repo.
Do not confuse them with submodules which are links to differents repositories.
You can create a folder in wich a branch of you repository is checked out.
Exemple for Github Pages with a specific branch providing the static files:
- Create the new orphan page: `git checkout --orphan gh-pages
- Clean all (untracked) files:
git reset --hardorgit rm -rf . - Create first commit:
git commit --allow-empty -m "Initializing gh-pages branch" - Push the new branch on your repo:
git push origin gh-pages - Get back to your main branch:
git checkout master - Create the worktree in a
publicfolder:git worktree add -B gh-pages public origin/gh-pages
Now, all the files put in the public folder can simply be committed and pushed to the gh-page branch.
The rest of your repo will stay in sync with your main branch.
To be sure to not mess with your main branch you can add the folder containing the worktree in your .gitignore file.
nice ๐