Git can’t push my project... and other commands are also giving fatal

Asked

Viewed 1,218 times

0

Hello again to all I’m going through a very boring problem... and so far I haven’t been able to identify.. Whenever I try to push or pull in my project I get the messages below, and nothing goes up there on github, please if anyone knows how to solve please help me I’m new in this git business and I’m pretty lost..., thanks from now on for your attention:

Obs: the code below is a test plus this occurs with other project folders as well..



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)
$


  • Carlos, use the command git remote -v and see if you have a repository origin listed. If not, type with this command git remote add origin

  • Colasanto Afternoon, I did what you asked and he informs me the following: RepositorioTeste https://github.com/Gustavocgsg/RepositorioTeste.git (fetch)&#xA;RepositorioTeste https://github.com/Gustavocgsg/RepositorioTeste.git (push)&#xA;origin https://github.com/Gustavocgsg/RepositorioTeste.git (fetch)&#xA;origin https://github.com/Gustavocgsg/RepositorioTeste.git (push)

1 answer

1


Your first push attempt was stopped because the target repository was in front of your local repository.

Since you made several changes, including creating a new repository within the current repository, this will cause a lot of inconvenience.

What I recommend is that you clone the repository again, take the files that you committed in this repository above, and manually put in the repository directory that you clone again, commit and then push.

WARNING: As your repository was behind your location, there are probably changes that form made there and your local code does not have, IE, you can kill what was already on the remote. I recommend using software like Winmerge to compare the local code with that of the cloned repository again, and see what is different.

  • I’ll try, but the weird thing is that in practice I don’t even have anymore repositories created on Github I deleted them all, I shouldn’t have given it conflict right? there is no way to undo everything and start from scratch again ?

  • 1

    Don’t you have a repository on Github or have you deleted and created again? If Gh is zeroed, it really shouldn’t have given conflict, but there are several commands running there in your "log", so it’s hard to tell the current situation and why.

  • Thank you so much for your help was very confused with everything ! now cleared the ideas

Browser other questions tagged

You are not signed in. Login or sign up in order to post.