Created
January 5, 2018 02:37
-
-
Save frasertweedale/b01674f442c2c032b88a051ac62fc2c3 to your computer and use it in GitHub Desktop.
Git: create an empty, orphan branch, in the background (e.g. gh-pages)
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
| [ -z "$1" ] && echo "usage: $0 BRANCH_NAME" && exit 1 | |
| export GIT_INDEX_FILE=$PWD/.git/index-empty | |
| REF=refs/heads/$1 | |
| git read-tree --empty | |
| TREE=$(git write-tree) | |
| COMMIT=$(git commit-tree "$TREE" -m "new empty orphan branch") | |
| git update-ref "$REF" "$COMMIT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment