Last active
September 7, 2021 09:40
-
-
Save atifaziz/59912c18c82d1b06cc24a427ec88aa8f to your computer and use it in GitHub Desktop.
Create an orphan branch without checking it out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git stash # 1. save index changes | |
git rm -r --cached . # 2. empty the index | |
git branch orphan ( # 5. create the orphan branch | |
git commit-tree -m 'Empty commit' ( # 4. commit the empty tree | |
git write-tree)) # 3. write the empty index | |
git reset HEAD # 6. revert emptying of the index | |
git stash pop --index # 7. restore stashed changes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment