Git push error ‘[remote rejected] master -> master (branch is currently checked out)’

The error message error: refusing to update checked out branch: refs/heads/master is emitted by the remote repository and it means you’re trying to push code to remote non-bare repository that has different code currently checked out in the working directory. The best way to avoid this problem is to push to bare repositories only – this problem cannot ever happen with a bare repository.

You can simply convert your remote repository to bare repository (there is no working copy in the bare repository – the folder contains only the actual repository data).

Execute the following command in your remote repository folder:

git config --bool core.bare true

Then delete all the files except .git in that folder. And then you will be able to perform git push to the remote repository without any errors.

Leave a Comment

tech