GitSamples-GIT switch --orphan: readme
I want examine if one could combine unrelated branches to create a topic branch with a README.md template at the top.
The use case for example in the FEDCBA branch we rebase only other branches containing files. At the end this should be documented in a README.md file on rebase-FEDCBA.
If its possible to add a readme template branch on top of the history, this could simplify the documentation in topic branches.
For this I created three branches.
- _empty: Contains .gitignore
- _readme commit Contains README.md template without history
- readme commit Contains README.md template based on _empty
The branches are created like this:
git switch --orphan _empty
// .... add .gitignore and commit
git switch --orphan _readme
// .... add README.md template and commit#
git checkout _readme
git checkout -b "readme"
git rebase _empty
The readme branch has now _empty in history:
git log --oneline
0af75cd (HEAD -> readme) _readme:init
4767389 (origin/_empty, _empty) empty:init
We have three different solutions described:
- switch-orphan-readme-cherry-pick: readme at the top.
- switch-orphan-readme-rebase: readme at the bottom.
- switch-orphan-readme-merge: readme before bottem.
With a cherry-pick one can combine orphan branches in the desired way.