Error pushing origin master on github

Asked

Viewed 36,730 times

7

I have the following error in github when I’m going to push.

Please make sure you have the correct access Rights and the Repository exists.

I created the repository and as I was already with the project created, I did:

git remote add [email protected]:andredsn/ArquiteturaSoftware.git
git config --global user.name "andredsn"
git config --global user.email "[email protected]"  
git add .  
git commit -m "primeiro commit"
git push origin master  

This last line gives the error. Probably not finding the repository.

Like the line:

git remote add [email protected]:andredsn/ArquiteturaSoftware.git >

add the remote via ssh, then deleted with:

git remote rm origim master  

I typed: Gite remote -v and there is no repository, so I think I removed it. But the error appears when I add the remote via https:

git remote add https://github.com/andredsn/ArquiteturaSoftware.git  

make a mistake:

 C:\projetos\ArquiteturaSoftware>git remote add https://github.com/andredsn/ArquiteturaSoftware.git
usage: git remote add [<options>] <name> <url>

    -f, --fetch           fetch the remote branches
    --tags                import all tags and associated objects when fetching
                          or do not fetch any tag at all (--no-tags)
    -t, --track <branch>  branch(es) to track
    -m, --master <branch>
                          master branch
    --mirror[=<push|fetch>]
                          set up remote as a mirror to push to or fetch from 

I wanted a command to show if I’m connected with github since we use the git config --global user.name and git config --global user.email for our identification.

  • 1

    Did you import your SSH key into Github? https://github.com/settings/keys

  • Have you tried this only with SSH? Try with HTTPS.

  • @Ricardo Moraleida I’m not using ssh and I’ve used it a few times before just by the terminal. I find ssh very laborious for those who use the terminal.

  • @Ack Lay I’m using as https myself.

  • You are doing this locally on your machine or some server?

  • @Ack Lay I’m doing in my local machine.

  • recommend using gitkraken makes it much easier to solve errors

  • Run the git remote -v command to see if I’m connected to github, so you’ll know your fetch and push origin. Remember that you need to be inside the folder that contains your . git

Show 3 more comments

3 answers

4


You used the SSH URL ([email protected]...) to add the remote, so it looks for your key.

The HTTPS URL has this format:

https://github.com/andredsn/ArquiteturaSoftware.git

then do:

$ git remote add https://github.com/andredsn/ArquiteturaSoftware.git

and it will ask for username and password.

(do not forget to remove remote SSH first)

4

If you want to perform this procedure using HTTPS, follow the steps below:

  1. $ git init : Do this already inside the desired directory

  2. $ git remote add -f origin https://github.com/andredsn/ArquiteturaSoftware.git

  3. $ git add .

  4. $ git commit -m "First commit - send project"

  5. $ git push origin master

See more details in the article on Working with Remote

EDIT: The error that is appearing there after editing your question is that you are not following GIT syntax correctly. Here’s how the basics should be:

$ git remote add [<opões>] <nome> <url>

In your case it would be step 2 as mentioned above. See:

$ git remote add -f origin https://github.com/andredsn/ArquiteturaSoftware.git

  • I erased the project, created another, your entire sequence in your response worked, except for step five. Gives error: > To https://github.com/andredsn/ArquiteturaSoftware.git ! [Rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/andredsn/ArquiteturaSoftw are.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. >

  • @Andrénascimento which error gives?!

  • When you type: git remote -v shows: > origin https://github.com/andredsn/ArquiteturaSoftware.git (push) > erre push between parentheses can indicate the possible error?

  • does not have this command git remote -v no Quito passo. E (push) do not want to indicate any error. I think your case has already been solved right?! Abs. Good luck. Good luck.

  • 1

    Almost solved. But thanks for the help, part of the way has already been covered.

-4

solved in this way:

git remote add origin https://github.com/bla.../bla bla ...
git branch -M main
git push -u origin main

Browser other questions tagged

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