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

前端 未结 30 2643
半阙折子戏
半阙折子戏 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:42

    Check your .git/config in the destination project:

    $ cat .git/config 
    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
    [receive]
        denyCurrentBranch = updateInstead
    

    If the core. bare is false, you can set it to true:

    $ git config core.bare true
    

    and then in your local push to remote:

    git push remote_repo   // suppose the destination repo is remote_repo
    

    it will success, in the remote_repo you can check git version.

    $ git log -1
    commit 0623b1b900ef7331b9184722a5381bbdd2d935ba
    Author: aircraft < aircraft_xxx@126.com>
    Date:   Thu May 17 21:54:37 2018 +0800
    

    and now you can not use git in your "workspace":

    $ git status
    fatal: This operation must be run in a work tree
    

    you should set bare.bare back to false.

    $ git config core.bare false
    

提交回复
热议问题