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

não consigo dar um push no meu projeto Git

Bom, estou aprendendo git e já estou me deparando com algum problema.

Criei meu repositório no github, e depois foi deletado, cri um novo e estou tentando mandar novamente e não estou conseguindo.. Segue meu erro.

agenda$ git push origin master
Username for 'https://github.com': daysonmota
Password for 'https://daysonmota@github.com': 
To https://github.com/daysonmota/CrossCode-Triadworks.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/daysonmota/CrossCode-Triadworks.git'
dica: Updates were rejected because the tip of your current branch is behind
dica: its remote counterpart. Integrate the remote changes (e.g.
dica: 'git pull ...') before pushing again.
dica: See the 'Note about fast-forwards' in 'git push --help' for details.
8 respostas

Dayson, tudo bem ?

Ele tá falando que você primeiro precisar estar com o seu repositorio local atualizado, para isso precisa dar um git pull e depois disso você consegue dar um push

Olá Matheus obrigado pela ajuda!

Bom, ao fazer o git pull apresenta isso:

dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=<remote>/<branch> master

dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$

Depois fiz isso:

dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$ git pull origin master
From https://github.com/daysonmota/CrossCode-Triadworks
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories
dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$

Depois fiz isso e ficou do mesmo jeito:

dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$ git push origin master
Username for 'https://github.com': daysonmota
Password for 'https://daysonmota@github.com': 
To https://github.com/daysonmota/CrossCode-Triadworks.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/daysonmota/CrossCode-Triadworks.git'
dica: Updates were rejected because the tip of your current branch is behind
dica: its remote counterpart. Integrate the remote changes (e.g.
dica: 'git pull ...') before pushing again.
dica: See the 'Note about fast-forwards' in 'git push --help' for details.
dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$

Olá Matheus obrigado pela ajuda!

Bom, ao fazer o git pull apresenta isso:

dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=<remote>/<branch> master

dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$

Depois fiz isso:

dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$ git pull origin master
From https://github.com/daysonmota/CrossCode-Triadworks
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories
dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$

Depois fiz isso e ficou do mesmo jeito:

dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$ git push origin master
Username for 'https://github.com': daysonmota
Password for 'https://daysonmota@github.com': 
To https://github.com/daysonmota/CrossCode-Triadworks.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/daysonmota/CrossCode-Triadworks.git'
dica: Updates were rejected because the tip of your current branch is behind
dica: its remote counterpart. Integrate the remote changes (e.g.
dica: 'git pull ...') before pushing again.
dica: See the 'Note about fast-forwards' in 'git push --help' for details.
dayson@Dayson:/media/dayson/Novo volume/Projetos/JavaScript projetos/TriadWorks/agenda$

faz um git pull origin master

Dayson, tenta esse comando:

git pull origin master --allow-unrelated-histories

Depois faz esse

git push origin master

Obrigado pela ajuda Vânia. antes disso fiz um git satus:

iadworks$ git status
No ramo master
Mudanças a serem submetidas:
  (use "git reset HEAD <file>..." to unstage)

    modified:   src/br/com/exercicios/MegaSennaTeste.java
    modified:   src/br/com/exercicios/NumeroMaisAltoTeste.java
    modified:   src/br/com/exercicios/RetornaArrayOrdenado.java

Changes not staged for commit:
  (utilize "git add <arquivo>..." para atualizar o que será submetido)
  (utilize "git checkout -- <arquivo>..." para descartar mudanças no diretório de trabalho)

    modified:   .classpath
    modified:   .gitignore
    modified:   .project
    modified:   .settings/org.eclipse.jdt.core.prefs
    modified:   src/br/com/exercicios/NumeroMaisAltoTeste.java
    modified:   src/br/com/exercicios/RetornaArrayOrdenado.java

Fiz o que você pediu:

git pull origin master --allow-unrelated-histories
From https://github.com/daysonmota/CrossCode-Exercicios
 * branch            master     -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
    src/br/com/exercicios/MegaSennaTeste.java
    src/br/com/exercicios/NumeroMaisAltoTeste.java
    src/br/com/exercicios/RetornaArrayOrdenado.java
Please commit your changes or stash them before you merge.
error: Your local changes to the following files would be overwritten by merge:
    .gitignore
Please commit your changes or stash them before you merge.
Aborting

Depois

git push origin master
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/daysonmota/CrossCode-Exercicios.git'
dica: Updates were rejected because the tip of your current branch is behind
dica: its remote counterpart. Integrate the remote changes (e.g.
dica: 'git pull ...') before pushing again.
dica: See the 'Note about fast-forwards' in 'git push --help' for details.

Ainda sem sucesso....

solução!

dayson,

você precisa commitar os arquivos antes de fazer o pull, o erro que aparece diz isso:

Please commit your changes or stash them before you merge.

faz o add, depois o commit e depois o comando que eu te falei.

git pull origin master --allow-unrelated-histories

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