Sanx
Sanx

Reputation: 323

need github without username and password

I want to upload a project to the repository, but the problem is that, when I run the command:

$ git push -u origin master

It shows me something like the following:

Username: 
Password: 
error: The requested URL returned error: 403 while accessing https://github.com/sanxelsanto/books3.git/info/refs

fatal: HTTP request failed

What should I do to avoid such an error message?

Upvotes: 2

Views: 1432

Answers (2)

uchamp
uchamp

Reputation: 2512

I ran into a similar problem with github and solved it by configuring my git repo over SSH instead of HTTP.

Step1: On the github.com page for your repo you will see three buttons HTTPS, SSH and Git Read Only. Click on "SSH" and copy the contents of the text field. Now there are a couple of ways you can change the configuration:

Step 2a: By editing the config file manually:
Open the .git folder of your repo and edit the config file. Look for [remote "origin"] and set the url config as follows:

[remote "origin"]
#The contents of the text field you copied in Step 1
url = [email protected]:<username>/<projectname>.git

Step 2b: With a git command:
Just run the following command (replace username and projectname variables):

git config remote.origin.url [email protected]:<username>/<projectname>.git

Step3: You can view/confirm the changes with the following command. Look for "remote.origin.url" config:

git config -l

Upvotes: 2

VonC
VonC

Reputation: 1324577

For an https address, git will use curl and will need a:

$HOME/.netrc

or (for Windows) a:

%HOME%/_netrc

(with %HOME% defined to any directory you want: HOME isn't defined by default)
Its content:

machine github.com
login <your_github_login>
password <your_github_password>

See "Git - How to use .netrc file on windows to save user and password".
Other parameters are detailed in "Syncing with github" (espacially if you are behind a firewall and need to specify a proxy).

Upvotes: 5

Related Questions