Error typing GIT PUSH

13

I'm on my machine and I want to upload the files on my local machine to my repository at github.com .

I have already executed the commands git add , git commit and only need to upload them. When I run git remote -v , it 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 this point, is it already set to push ? If yes, when I run 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.

    
asked by anonymous 15.03.2017 / 19:01

3 answers

12

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

git push teste branchDeTrabalho
    
15.03.2017 / 19:03
12

Git is already giving you the solution. Use 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 are going to push. Using this command you will only need to make this branch association once, in the next push git will no longer ask for the association and you can only run git push without entering the branch name.

    
15.03.2017 / 19:14
2

There is a shortcut that can be used:

git push -u origin master

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

    
29.03.2017 / 03:22