3
respostas

Falha no push

Na hora que fazer o push do master para local deu erro.

$ git remote
local
origin

Wanderson@DESKTOP-FC3NU3L MINGW64 ~/.git2 (master)
$ git push local master
Enumerating objects: 14, done.
Counting objects: 100% (14/14), done.
Delta compression using up to 4 threads
Compressing objects: 100% (12/12), done.
Writing objects: 100% (14/14), 1.87 KiB | 119.00 KiB/s, done.
Total 14 (delta 1), reused 0 (delta 0), pack-reused 0
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To c:/Users/Wanderson/servidor/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'c:/Users/Wanderson/servidor/'
3 respostas

Olá, Ana. Tudo bem?

Aparentemente, segundo a mensagem do erro - By default, updating the current branch in a non-bare repository is denied - você deve ter esquecido de iniciar o repositório com o git init --bare.

Será que você não executou o git init sem o --bare?

Devo executar o git init --bare em qual diretorio? Eu executei no /.git2 (master) e deu o mesmo erro.

Oi, Ana.

Se o repositório que você quer usar como bare estiver ainda vazio, se você não tiver usado ele como um repositório normal, você pode usar o comando git config --bool core.bare true para transformar em bare.

No caso do curso, você poderia simplemente remover a pasta .git e iniciar o repositório com git init --bare, já que o foco aqui não é executar essas atividades mais específicas.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software