0

Olá mais uma vez a todos estou passando por um problema bem chato... e até o momento não consegui identificar.. sempre que tento dar push ou pull em meu projeto recebo as mensagens abaixo, e não sobe nada lá no github, por favor se alguém souber resolver por favor me ajude sou novo nesse negócio de git e estou bem perdido..., grato desde já por sua atenção:

obs: o código abaixo é um teste mais isso ocorre co outras pastas de projeto também..



gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git add .

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git commit -m "subir novo projeto"
On branch master
nothing to commit, working tree clean

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git push branch master                                                     
fatal: 'branch' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git push origin  master
To https://github.com/Gustavocgsg/RepositorioTeste.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/Gustavocgsg/RepositorioTeste.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git pull origin master
From https://github.com/Gustavocgsg/RepositorioTeste
 * branch            master     -> FETCH_HEAD       
 * [new branch]      master     -> origin/master    
fatal: refusing to merge unrelated histories

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git status
On branch master
nothing to commit, working tree clean

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git fetch

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git status
On branch master
nothing to commit, working tree clean

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git merge
fatal: No remote for the current branch.

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git remote https://github.com/Gustavocgsg/RepositorioTeste.git
error: Unknown subcommand: https://github.com/Gustavocgsg/RepositorioTeste.git
usage: git remote [-v | --verbose]
   or: git remote add [-t <branch>] [-m <master>] [-f] [--tags | --no-tags] [--mirror=<fetch|push>] <name> <url>
   or: git remote rename <old> <new>
   or: git remote remove <name>
   or: git remote set-head <name> (-a | --auto | -d | --delete | <branch>)
   or: git remote [-v | --verbose] show [-n] <name>
   or: git remote prune [-n | --dry-run] <name>
   or: git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
   or: git remote set-branches [--add] <name> <branch>...
   or: git remote get-url [--push] [--all] <name>
   or: git remote set-url [--push] <name> <newurl> [<oldurl>]
   or: git remote set-url --add <name> <newurl>
   or: git remote set-url --delete <name> <url>

    -v, --verbose         be verbose; must be placed before a subcommand


gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git remote -v
RepositorioTeste        https://github.com/Gustavocgsg/RepositorioTeste.git (fetch)
RepositorioTeste        https://github.com/Gustavocgsg/RepositorioTeste.git (push)
origin  https://github.com/Gustavocgsg/RepositorioTeste.git (fetch)
origin  https://github.com/Gustavocgsg/RepositorioTeste.git (push)

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git remote RepositorioTeste
error: Unknown subcommand: RepositorioTeste
usage: git remote [-v | --verbose]
   or: git remote add [-t <branch>] [-m <master>] [-f] [--tags | --no-tags] [--mirror=<fetch|push>] <name> <url>
   or: git remote rename <old> <new>
   or: git remote remove <name>
   or: git remote set-head <name> (-a | --auto | -d | --delete | <branch>)
   or: git remote [-v | --verbose] show [-n] <name>
   or: git remote prune [-n | --dry-run] <name>
   or: git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
   or: git remote set-branches [--add] <name> <branch>...
   or: git remote get-url [--push] [--all] <name>
   or: git remote set-url [--push] <name> <newurl> [<oldurl>]
   or: git remote set-url --add <name> <newurl>
   or: git remote set-url --delete <name> <url>

    -v, --verbose         be verbose; must be placed before a subcommand


gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git clone https://github.com/Gustavocgsg/RepositorioTeste.git
Cloning into 'RepositorioTeste'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git status
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    index.html

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        RepositorioTeste/

no changes added to commit (use "git add" and/or "git commit -a")

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git add .
warning: adding embedded git repository: RepositorioTeste
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint: 
hint:   git submodule add <url> RepositorioTeste
hint: 
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint: 
hint:   git rm --cached RepositorioTeste
hint: 
hint: See "git help submodule" for more information.

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git add .

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git commit -m "nova tentativa de subir arquivos"
[master 2b87106] nova tentativa de subir arquivos
 2 files changed, 1 insertion(+)
 create mode 160000 RepositorioTeste
 rename index.html => index_v1.html (100%)

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git push
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 origin master


gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$ git push origin master
To https://github.com/Gustavocgsg/RepositorioTeste.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/Gustavocgsg/RepositorioTeste.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

gusta@GUSTAVO-PC MINGW64 /c/RepositorioTeste (master)
$


2

1 Resposta 1

1

A sua primeira tentativa de fazer o push foi impedida por que o repositório de destino estava a frente do seu repositório local.

Como você fez diversas alterações, inclusive criou um repositório novo dentro do repositório atual, isso vai causar bastante transtorno.

O que eu recomendo é você clonar o repositório novamente, pegar os arquivos que você fez commit neste repositório acima, e colocar manualmente no diretóri do repositório que você clonar novamente, fazer o commit e daí o push.

ATENÇÃO: Como o seu repositório estava atrás do seu local, provavelmente existem alterações que forma feitas lá e o seu código local não tem, ou seja, você pode matar o que já estava no remoto. Recomendo usar um software como o Winmerge para comparar o código local com o do repositório clonado novamente, e ver o que está diferente.

3
  • vou tentar, mais o esquisito é que na pratica nem tenho mais repositórios criados no Github apaguei todos, não deveria ter dado conflito né? não há uma forma que desfazer tudo e começar do zero novamente ? 15/07/2020 às 18:07
  • 1
    Você não tem repositório no Github ou você refez deletou e criou novamente? Se no Gh está zerado, realmente não deveria ter dado conflito, mas tem vários comando executados aí no seu "log", então é difícil de dizer a situação atual e o motivo. Dica: use sempre o comando git status, pois ajuda a saber a situação atual do repositório, o problema que está acontecendo, e principalmente, como resolvê-lo 17/07/2020 às 12:44
  • Muito obrigado por sua ajuda estava muito confuso com tudo ! agora clareou as ideias 17/07/2020 às 23:14

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .