diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-11-18 06:26:43 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-11-18 06:26:43 -0200 |
commit | 8b56dface439ff13c9977d958b891bfb79b09850 (patch) | |
tree | b77f9891674b8f2146eaba8821369fba21a1e10a | |
parent | 1cde5d6f043cd3fb29ec4d60827c66e9a19ed405 (diff) | |
download | utils-git-8b56dface439ff13c9977d958b891bfb79b09850.tar.gz utils-git-8b56dface439ff13c9977d958b891bfb79b09850.tar.bz2 |
Avoid detached HEAD
-rwxr-xr-x | commit | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -131,6 +131,12 @@ function git_commit { # Remove '--config' from args, otherwise it goes to the commit log params="`echo $* | sed -e 's/--config//'`" + # Avoid detached HEAD + if $GIT branch | grep -q '^* (HEAD detached'; then + echo "Beware: trying to commit in detached HEAD state; checkout to a branch first" + exit 1 + fi + # If there are no staged files, commit everything. # Otherwise commit just what was staged if $GIT status --short | grep -q "^[AM]"; then |