git push fails: `refusing to update checked out branch: refs/heads/master`

后端 未结 6 1969
抹茶落季
抹茶落季 2020-12-04 17:48

I want to store my local modifications to JBoss config in git. For this, I have set up the following structure:

lrwxrwxrwx  1 jboss jboss        19 Jan 24 11         


        
相关标签:
6条回答
  • 2020-12-04 17:54

    Pushing is meant for bare repos. For non-bare repos you should pull into them.

    If you want to force this through anyway, you can do as the error message states and set receive.denyCurrentBranch to ignore. SSH to the location of the repo you are pushing to and run:

    git config receive.denyCurrentBranch ignore
    
    0 讨论(0)
  • 2020-12-04 18:03

    I know this is quite an old question, but if you go with git init --bare, watch out for 'GIT_DIR=.' which will be set for a bare repo hook if using hooks to checkout the repo after pushing. Use 'export GIT_DIR=.git' in your hook routine to make it recognise the repo you are pulling into....

    0 讨论(0)
  • 2020-12-04 18:04

    Create the origin (local) repository as a bare repository (ie. git init --bare), or checkout a branch in there which is not master.

    0 讨论(0)
  • 2020-12-04 18:08

    I managed to get round this by pulling from 'local' in 'current' rather than pushing to 'current' from 'local'.

    0 讨论(0)
  • 2020-12-04 18:10

    The master branch at remote site is checked out. If you have access to remote repository, checkout any other branch and then push from your repository.

    0 讨论(0)
  • 2020-12-04 18:10

    OR,

    when you initialize your remote project, using

    git init --bare
    
    0 讨论(0)
提交回复
热议问题