Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Erro ao digitar comando git push local master

Aparentemente a minha dificuldade é a mesma relatada na pergunta: https://cursos.alura.com.br/forum/topico-erro-ao-digitar-comando-git-push-local-master-90626, entretanto fui a pasta servidor e apliquei o comando git init --bare com sucesso, mas ao voltar a pasta vinicius e aplicar o push o erro permanece.

/alura/git_github/local/vinicius (master)
$ git push local master
Enumerating objects: 12, done.
Counting objects: 100% (12/12), done.
Delta compression using up to 8 threads
Compressing objects: 100% (10/10), done.
Writing objects: 100% (12/12), 1.48 KiB | 756.00 KiB/s, done.
Total 12 (delta 0), 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/elyss/onedrive/Área de Trabalho/COTUCA_DS/alura/git_github/servidor
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'C:/users/elyss/onedrive/Área de Trabalho/COTUCA_DS/alura/git_github/servidor'
1 resposta
solução!

Achei isso aqui no StackOverFlow:

I just had the same error while I began learning Git. Some of the other answers are clearly not for someone new to Git!

(I am going to use non technical terms to get the idea across.) Anyway, what is happening is that you have two repositories, one is the original you first made, and the other the work one you just made.

Right now you are in your work repository and are using the "master" branch. But you also happen to be "logged in" in your original repository to the same "master" branch. Now since you're "logged in" in the original, Git fears you might mess up because you might be working on the original and screw things up. So you need to return to the original repository and do a "git checkout someotherbranch", and now you can push with no problems.

I hope this helps.

Vou traduzir pro caso de você não entender algo.

Tradução:

"Eu tive esse mesmo erro quando eu comecei a estudar Git. Algumas das outras respostas (do post do StackOverFlow que eu linkei ali em cima) são claramente pra quem já sabe um pouco mais de Git (Não iniciantes)."

"(Não vou usar termos técnicos pra facilitar seu entendimento.) Então, o que está acontecendo é que você tem 2 repositórios, um é o original que você fez primeiro, o outro é o 'trabalho'* que você acabou de fazer."

*Eu entendi esse "work" que foi usado ali como as alterações que você fez nos arquivos dentro desse repositório novo.

Agora voce está no seu repositório de 'trabalho' e usando a branch "master". Mas você também está "logado" no seu repositório original na mesma branch "master". Agora, como você está "logado" no seu repositório original, o Git teme que você bagunce tudo já que você pode estar trabalhando no original e estragar tudo. Então você precisa voltar ao repositório original e fazer um "git checkout algumaOutraBranch", e assim você vai conseguir fazer o push sem problemas.

Eu espero que isso ajude.

Se ainda assim não funcionar me diga que a gente tenta solucionar.

P.S.: O * é um comentário meu.

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