开发者

problem in pushing to github

开发者 https://www.devze.com 2023-03-29 16:25 出处:网络
I have created a repository on github named pygame. Created a clone and added files and commited.but when I attempt to push I receive the following error:

I have created a repository on github named pygame. Created a clone and added files and commited.but when I attempt to push I receive the following error:

git push -u origin master

error: The requested URL returned error: 403 while accessing https://github.com/am开发者_如何学Goalapk/pygame/info/refs

fatal: HTTP request failed

I can ssh to git@github.com and receive the notice that I logged in successfully, but can't push to my repository.


I recently experienced this problem when setting up a new clone of my github project.

You need to include your username in the URL to your project, in the form

https://user@github.com/project/...

For example, the URL provided for my test github is this:

https://github.com/jdblair/test.git

If I add my username to it, like this, then I'm able to push and pull from github with no problem:

https://jdblair@github.com/jdblair/test.git

It is easiest to use the URL that contains the username starting from when you clone a project.

You can change the URL for an existing project like this:

git remote set-url origin https://user@github.com/project/foo/bar.git

You can use the ssh authentication instead if you want, but that's a separate setup process.


Github now is asking us to use git 1.7.10 or later:

https://help.github.com/articles/error-the-requested-url-returned-error-403


The GitHub Remote page mentions the read/write addresses for a repo:

Make sure your clone address is like:

https://github.com/username/yourRepo.git

And that you have defined:

git config --global user.name "Firstname Lastname"
git config --global user.email "your_email@youremail.com"

Should you use a git address (without ssh), you would also need:

git config --global github.user username
git config --global github.token 0123456789yourf0123456789token # no longer needed

(with your token coming from “Account Settings” > Click “Account Admin.”)

Update 2013: you still can generate a token (see "Creating an access token for command-line use"), but you would use it as a password for https url.

Actually, if you activate the 2FA (two-factor authentication) mechanism on GitHub, you will need a token for your https url (because your regular password would trigger the second-step verification).
See "Configure Git clients, like GitHub for Windows, to not ask for authentication"

See more at "Which remote URL should I use?".


It's all in the remote.

Change your current remote from https://github.com/amalapk/pygame.git to git@github.com:amalapk/pygame.git and enjoy.

To do this... (assuming your current remote is called origin)

git remote set-url origin git@github.com:amalapk/pygame.git


In my case getting rid of such error message was resolved this way: Person was simply added to github repository as a colaborator. Thats it - error vanished magically.


Committing to github from server this is what worked for me in the terminal or git bash

To create a remote to github.com try:

git remote add origin https://put your username here@github.com/put your git username here/put your repository name here

To change the remote just do:

git remote set-url origin https://put your username here@github.com/put your git username here/the name of your repository here


Please follow the instructions on http://help.github.com/create-a-repo/

You have cloned your repository with the public read only url.

RTFM

0

精彩评论

暂无评论...
验证码 换一张
取 消