aboutsummaryrefslogtreecommitdiff
path: root/git-checkout.sh
diff options
context:
space:
mode:
Diffstat (limited to 'git-checkout.sh')
-rwxr-xr-xgit-checkout.sh16
1 files changed, 11 insertions, 5 deletions
diff --git a/git-checkout.sh b/git-checkout.sh
index 92ec069a3..8e11ca4bc 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -144,13 +144,19 @@ fi
# are switching to, then we'd better just be checking out
# what we already had
-[ -z "$branch$newbranch" ] &&
- [ "$new" != "$old" ] &&
- die "git checkout: provided reference cannot be checked out directly
-
- You need -b to associate a new branch with the wanted checkout. Example:
+if test -z "$branch$newbranch" && test "$new" != "$old"
+then
+ # NEEDSWORK: we would want to have this command here
+ # that allows us to detach the HEAD atomically.
+ # git update-ref --detach HEAD "$new"
+ rm -f "$GIT_DIR/HEAD"
+ echo "$new" >"$GIT_DIR/HEAD"
+ echo >&2 "WARNING: you are not on ANY branch anymore.
+If you meant to create a new branch from the commit, you need -b to
+associate a new branch with the wanted checkout. Example:
git checkout -b <new_branch_name> $arg
"
+fi
if [ "X$old" = X ]
then