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

前端 未结 30 2294
半阙折子戏
半阙折子戏 2020-11-22 00:07

Yesterday, I posted a question on how to clone a Git repository from one of my machines to another, How can I \'git clone\' from another machine?.

I am now

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 00:40

    You can get around this "limitation" by editing the .git/config on the destination server. Add the following to allow a git repository to be pushed to even if it is "checked out":

    [receive]
    denyCurrentBranch = warn
    

    or

    [receive]
    denyCurrentBranch = false
    

    The first will allow the push while warning of the possibility to mess up the branch, whereas the second will just quietly allow it.

    This can be used to "deploy" code to a server which is not meant for editing. This is not the best approach, but a quick one for deploying code.

提交回复
热议问题