Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

git push local master - error

Ao digitar comando aparece a seguinte mensagem:

Enumerating objects: 9, done.

Counting objects: 100% (9/9), done.

Delta compression using up to 8 threads

Compressing objects: 100% (6/6), done.

Writing objects: 100% (9/9), 923 bytes | 923.00 KiB/s, done.

Total 9 (delta 1), reused 0 (delta 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 /Users/danilo/Documents/git-e-github/servidor/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/Users/danilo/Documents/git-e-github/servidor/'

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream local master
3 respostas

Olá Danilo, tudo bem? Esse erro parece ser porque o repositório "servidor" não foi iniciado com a flag --bare, esses são chamados de repositórios vazios e não têm uma cópia de trabalho, assim você pode enviar por push para eles. Como solução você pode tentar "excluir" e "criar" novamente a pasta "servidor" e depois dentro dela executar o seguinte comando:

git init --bare

E fala pra gente se funcionou!

Realizei o procedimento conforme orientado, Jonilson. Porém o problema continua. Agora dá o seguinte erro:

Reinitialized existing Git repository in /Users/danilo/Documents/git-e-github/servidor/ fatal: this operation must be run in a work tree

Aliás, o erro acima ocorre quando dentro da pasta servidor digito git init --bare

solução!

Encontrei o erro. Havia esquecido de fazer o rename: git remote rename origin local

Problema resolvido!