Skip to content

Commit 1510dbe

Browse files
mattmccutchengitster
authored andcommitted
git checkout: don't warn about unborn branch if -f is already passed
I think it's unnecessary to warn that the checkout has been forced due to an unborn current branch if -f has been explicitly passed. For one project, I am using git-new-workdir to create workdirs from a bare repository whose HEAD is set to an unborn branch, and this warning started to irritate me. Signed-off-by: Matt McCutchen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c078383 commit 1510dbe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin-checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
421421
if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
422422
describe_detached_head("Previous HEAD position was", old.commit);
423423

424-
if (!old.commit) {
424+
if (!old.commit && !opts->force) {
425425
if (!opts->quiet) {
426426
fprintf(stderr, "warning: You appear to be on a branch yet to be born.\n");
427427
fprintf(stderr, "warning: Forcing checkout of %s.\n", new->name);

0 commit comments

Comments
 (0)