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

nao consigo realizar a funcao git push -u origin main

PS C:\Users\iigor\OneDrive\Área de Trabalho\Curso DEV allura ONE\projetos JavaScript ALLura ONE G9\Projeto Jogo Numero Secreto> git push -u origin main
The authenticity of host 'github.com (20.201.28.151)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
Connection closed by 20.201.28.151 port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
PS C:\Users\iigor\OneDrive\Área de Trabalho\Curso DEV allura ONE\projetos JavaScript ALLura ONE G9\Projeto Jogo Numero Secreto> ssh-keygen -t ed25519 -C "iigor.sg@gmail.com"
Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\iigor/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\iigor/.ssh/id_ed25519
Your public key has been saved in C:\Users\iigor/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:jCx8zvAHWMoUjyaeCAegEXgnV8gFR9tRbl9fV7dmPCY iigor.sg@gmail.com
The key's randomart image is:
+--[ED25519 256]--+
|B. .o*= ... o|
|ooo == o o . +|
|o.o++ + . o E.Bo|
|.+ B = o . . .=.+|
|. o B = S . .|
| B . |
| + . |
| . |
| |
+----[SHA256]-----+
PS C:\Users\iigor\OneDrive\Área de Trabalho\Curso DEV allura ONE\projetos JavaScript ALLura ONE G9\Projeto Jogo Numero Secreto>
PS C:\Users\iigor\OneDrive\Área de Trabalho\Curso DEV allura ONE\projetos JavaScript ALLura ONE G9\Projeto Jogo Numero Secreto> git push -u origin main
To github.com:Igor2sGomes/Jogo-do-numero-secreto.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'github.com:Igor2sGomes/Jogo-do-numero-secreto.git'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
PS C:\Users\iigor\OneDrive\Área de Trabalho\Curso DEV allura ONE\projetos JavaScript ALLura ONE G9\Projeto Jogo Numero Secreto> git pull origin main
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 14 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (14/14), 1.91 MiB | 2.29 MiB/s, done.
From github.com:Igor2sGomes/Jogo-do-numero-secreto

  • branch main -> FETCH_HEAD
  • [new branch] main -> origin/main
    fatal: refusing to merge unrelated histories
    PS C:\Users\iigor\OneDrive\Área de Trabalho\Curso DEV allura ONE\projetos JavaScript ALLura ONE G9\Projeto Jogo Numero Secreto> git push -u origin main
    To github.com:Igor2sGomes/Jogo-do-numero-secreto.git
    ! [rejected] main -> main (non-fast-forward)
    error: failed to push some refs to 'github.com:Igor2sGomes/Jogo-do-numero-secreto.git'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. If you want to integrate the remote changes,
    hint: use 'git pull' before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    PS C:\Users\iigor\OneDrive\Área de Trabalho\Curso DEV allura ONE\projetos JavaScript ALLura ONE G9\Projeto Jogo Numero Secreto>
    PS C:\Users\iigor\OneDrive\Área de Trabalho\Curso DEV allura ONE\projetos JavaScript ALLura ONE G9\Projeto Jogo Numero Secreto> git pull origin main
    From github.com:Igor2sGomes/Jogo-do-numero-secreto
  • branch main -> FETCH_HEAD
    fatal: refusing to merge unrelated histories
    PS C:\Users\iigor\OneDrive\Área de Trabalho\Curso DEV allura ONE\projetos JavaScript ALLura ONE G9\Projeto Jogo Numero Secreto> git push -u origin main
    To github.com:Igor2sGomes/Jogo-do-numero-secreto.git
    ! [rejected] main -> main (non-fast-forward)
    error: failed to push some refs to 'github.com:Igor2sGomes/Jogo-do-numero-secreto.git'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. If you want to integrate the remote changes,
    hint: use 'git pull' before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    PS C:\Users\iigor\OneDrive\Área de Trabalho\Curso DEV allura ONE\projetos JavaScript ALLura ONE G9\Projeto Jogo Numero Secreto>
    PS C:\Users\iigor\OneDrive\Área de Trabalho\Curso DEV allura ONE\projetos JavaScript ALLura ONE G9\Projeto Jogo Numero Secreto> git branch
  • main
1 resposta
solução!

Oi Igor! Tudo bem?

O erro "fatal: refusing to merge unrelated histories" indica que o histórico do repositório local e do remoto não estão relacionados. Isso pode acontecer quando você inicia um repositório local e tenta empurrar para um repositório remoto que já tem commits.

Aqui está uma maneira de resolver isso:

  1. Forçar o merge dos históricos: Você pode usar a opção --allow-unrelated-histories ao fazer o git pull. Isso irá permitir que você mescle os históricos não relacionados. Tente o seguinte comando:

    git pull origin main --allow-unrelated-histories
    
  2. Resolver conflitos, se houver: Após o comando acima, pode ser que você precise resolver conflitos de merge. Abra os arquivos indicados, resolva os conflitos e depois faça um commit:

    git add .
    git commit -m "Resolvendo conflitos de merge"
    
  3. Empurrar as mudanças para o repositório remoto: Agora, você deve conseguir fazer o push:

    git push -u origin main
    

Esse processo deve ajudar a alinhar os históricos do seu repositório local e remoto. Lembre-se de sempre verificar se há mudanças no repositório remoto antes de começar a trabalhar localmente, usando git pull, para evitar esses tipos de conflitos no futuro.

Espero ter ajudado e bons estudos!

Caso este post tenha lhe ajudado, por favor, marcar como solucionado ✓.