3
respostas

[Bug] Não consigo git push

coloquei o comando push origin main no terminal e apareceu uma mensagem de erro:

PS C:\Users\Anatalia\space-app> git init
Initialized empty Git repository in C:/Users/Anatalia/space-app/.git/
PS C:\Users\Anatalia\space-app> git commit -m "first"

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore
        README.md
        index.html
        package-lock.json
        package.json
        public/
        vite.config.js

nothing added to commit but untracked files present (use "git add" to track)
PS C:\Users\Anatalia\space-app> git add .
warning: in the working copy of '.gitignore', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'index.html', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'package-lock.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'package.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'public/imagens/sociais/facebook.svg', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'public/imagens/sociais/instagram.svg', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'public/imagens/sociais/twitter.svg', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/App.jsx', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/main.jsx', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'vite.config.js', LF will be replaced by CRLF the next time Git touches it
PS C:\Users\Anatalia\space-app> git commit -m "first"
[master (root-commit) 2d931cc] first
 56 files changed, 7341 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 README.md
 create mode 100644 index.html
 create mode 100644 
 ( linhas apagadas!... )
PS C:\Users\Anatalia\space-app> git remote add origin git@github.com:AnataliaCandido/space-app.git
PS C:\Users\Anatalia\space-app> git push origin main
error: src refspec main does not match any
error: failed to push some refs to 'github.com:AnataliaCandido/space-app.git'
PS C:\Users\Anatalia\space-app> git remote add origin git@github.com:AnataliaCandido/space-app.git
error: remote origin already exists.
PS C:\Users\Anatalia\space-app> git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'github.com:AnataliaCandido/space-app.git'

o repositório remoto já foi criado no git. poderia me ajudar?

3 respostas

Anatalia, isso acontece pq vc ta enviando pra uma branch que não existe, a brach é master, mas vc ta enviando para main Insira aqui a descrição dessa imagem para ajudar na acessibilidade

é só alterar o comando para master ao invés de main.

Caso queira alterar o nome da branch master para main use o seguinte comando: git branch -m master main

Anatalia, renomeie o nome da sua branch para main. Utilize o seguinte comando:

git branch -M main

[master (root-commit) 2d931cc] first**** O arquivo está na branch master e você usando o push main.

Solução usar: git push origin master

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