git refuses to push to a branch that is currently checked out in a non-bare repository. When the clone's origin is the user's local repo, this blocks merge_and_push entirely. On "branch is currently checked out" error, temporarily set receive.denyCurrentBranch=updateInstead on the remote and retry. This uses git's built-in mechanism to update the working tree safely (rejects if dirty).