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

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

    You will need to change the config file on the remote server once you have created empty(bare) repository, say

    root@development:/home/git/repository/my-project# cat config 
    

    there you will see

    [core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    

    You will make this bare to false to true and I removed logallrefupdates = true (not sure of its use!)

    to

    [core]
    repositoryformatversion = 0
    filemode = true
    bare = true
    

    You may test following

    $ git remote show origin
    * remote origin
    Fetch URL: my-portal@development:/home/XYZ/repository/XYZ
    Push  URL: my-portal@development:/home/XYZ/repository/XYZ
    HEAD branch: (unknown)
    

    This HEAD branch: (unknown) will be shown if you are unable to PUSH. So if the HEAD branch is unknow, you should change bare to true and after push successful you can reuse the

    git remote show origin
    

    and you will see

     HEAD branch: master
    

提交回复
热议问题