Created
March 26, 2009 08:04
-
-
Save koraktor/85964 to your computer and use it in GitHub Desktop.
Git: Creating an empty branch
This file contains 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 # Stash changes if any | |
git symbolic-ref HEAD refs/heads/${NEW_BRANCH} # Change head to a new, non-existing ref | |
git rm -rf . # Delete files from version control and working directory | |
rm -r . # Delete files from file system | |
git commit --allow-empty -m "Created new branch ${NEW_BRANCH}" # Commit changes in the new branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
git checkout --orphan new
will create a new branch with zero commits on it, however all of your files will be staged. At that point you could just remove them. Then create a dummy file, write something and push it to origin. Then a history will be created for your branch and you will be able to see your new branch when you dogit branch