Error typing GIT PUSH

Asked

Viewed 12,128 times

16

I’m on my machine and want to upload the files on my local machine to my repository on github with..

I’ve already executed the commands git add, git commit and all that remains is to raise them. When I execute git remote -v, returns the following:

$ git remote -v
origin  [email protected]:romulosousa27/php.git (fetch)
origin  [email protected]:romulosousa27/php.git (push)
otigin  git.github.com:romulosousa27/php.git (fetch)
otigin  git.github.com:romulosousa27/php.git (push)
teste   https://github.com/romulosousa27 (fetch)
teste   https://github.com/romulosousa27 (push)

At that point, he’s already prepared for the push? If yes , when I execute the command git push, this is returned:

$ 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

P.S: My Key SSH is already configured.

6 answers

16


git is already giving you the solution. Uses the command:

git push --set-upstream origin master

Where origin is the name you put when you used the command git remote add, and master is the name of the branch you push. Using this command you will only need to make this branch association once, in the next pushes git will no longer ask for the association and you can only run git git push without giving the branch name.

  • $ git push --set-upstream origin master ERROR: Repository not found. fatal: Could not read from remote Repository. Please make sure you have the correct access Rights and the Repository exists.

  • This github.com/romulosousa27/php.git repository doesn’t really exist. I checked with github and couldn’t find it. Did you leave it private? If yes, check the permissions in the project to clone/push.

  • Actually it doesn’t exist, I figured when I push it it would create a default repository... I used the github interface and thought it was the same principle, so I have to create a repository, clone and commission it?

  • That’s right, you need to create the project on github and then you associate your local project directory with the remote project using git remote add. As soon as you create it shows a page with the necessary commands to associate an existing local project to the remote.

  • Pow Uiliana worked out here, was just create the same repository. Thanks even, you made a child happy today hehe

15

It is not enough to write only git push, it is necessary to write which remote and the branch which will be updated.
Example:

git push teste branchDeTrabalho
  • 1

    That branch would be the origin master or path to the repository?

  • the path is already recorded in the remote (origin), the branch is the master, or any other branch you have checked out

2

There is a shortcut that can be used:

git push -u origin master

The parameter -u means your local branch will be configured to track the new branch master created in the repository origin. If the master branch does not exist in the remote repository, it will be created, otherwise it will be updated.

1

Step by step to push into a remote repository without major problems:

The following commands must be executed within a local repository, already initialized with git init.

Add a remote repository:

git remote add origin https://usuario-e-repositorio-do-github-ou-bitbucket

(if you have problems with git remote add)

By default, the git command refuses to merge histories that do not share a common ancestor. The first command below will be used to ignore this:

git pull --allow-unrelated-histories

Download what is in the remote repository, do it even if it is empty:

git pull origin master

Will be added to stagging the directory files and subdirectories you are:

git add .

Identify what you will climb...

git commit -m "Mensagem para esse push"

Upload:

git push origin master

1

Actually just follow the step by step after creating the repository on github. Then you use:

git add remote "link do repositorio"

Then you use the:

git init
git add *
git commit -m "Comentario"

and finally

git push origin master

0

Give a Git Pull before just typing..

git push -u https://github.com/nome do repositorio/nome do projeto master -f 

Oh yes put the git push https://github.com/repositorio/nomedoprojeto

Browser other questions tagged

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