Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fluentcodes/GitSamples-GIT

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

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.

Prepare

Orphan 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

README.md branches

We have three different solutions described:

Conclusion

With a cherry-pick one can combine orphan branches in the desired way.

Related Branches

Links

About

GitSamples for GIT using Topic Branches for elementary git operation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published