top of page
Search

Git: Orphan Branch






Create a git orphan branch to update your GitHub public repository while keeping the commit history hidden.


Here is how to do this:


my_branch: name of the branch to remove the commit history


my_new_tmp_branch: The name of a new temporary branch



First step: complete your work in my_branch, add and commit your changes


Next:


git checkout --orphan my_new_tmp_branch
git add -A
git commit -m "Initial commit"
git branch -D my_branch
git branch -m my_branch
git push -f origin my_branch


When you create an orphan branch, it starts with a completely empty working directory and no commit history, as if it were a brand new repository.


Visit Datanota full-stack GitHub repository: https://github.com/datanota/full-stack


Tags:

10 views

Comments


bottom of page