Skip to content

Instantly share code, notes, and snippets.

@dasJ
Created March 10, 2017 13:27
Show Gist options
  • Save dasJ/527f27773ec93f000270183f6cd0cec8 to your computer and use it in GitHub Desktop.
Save dasJ/527f27773ec93f000270183f6cd0cec8 to your computer and use it in GitHub Desktop.
git-emptybranch
#!/bin/bash
# Create a git branch with a single commit that contains nothing.
if [ "${#}" != 1 ]; then
echo "Usage: ${0} [branch name]"
exit 1
fi
tree="$(: | git mktree)"
commit="$(git commit-tree "${tree}" -m "Initial commit")"
git branch "${1}" "${commit}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment