diff --git a/lib/ansible/modules/source_control/git.py b/lib/ansible/modules/source_control/git.py index 4b1620392a0..d42b284abc5 100644 --- a/lib/ansible/modules/source_control/git.py +++ b/lib/ansible/modules/source_control/git.py @@ -453,7 +453,7 @@ def is_local_branch(git_path, module, dest, branch): def is_not_a_branch(git_path, module, dest): branches = get_branches(git_path, module, dest) for b in branches: - if b.startswith('* ') and 'no branch' in b: + if b.startswith('* ') and ('no branch' in b or 'detached from' in b): return True return False