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?
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).
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 = git#github.com:<username>/<projectname>.git
Step 2b: With a git command:
Just run the following command (replace username and projectname variables):
git config remote.origin.url git#github.com:<username>/<projectname>.git
Step3: You can view/confirm the changes with the following command. Look for "remote.origin.url" config:
git config -l
Related
in Visual studio code
i spent a lot more time for this, I'm trying push my deleted project that is coming from 1st account github into an existing repository in new another account, but I'm getting error like this :
$ git push -u origin main
remote: Permission to username/project_name.git denied to first_account_username.
fatal: unable to access 'https://github.com/user_name/project_name.git/': The requested URL returned error: 403
i tried those command line for push an existing repository in new account, please let me know what'd i miss ?
git remote add origin https://github.com/user_name/project_name.git
git branch -M main
git push -u origin main
Git obviously tries to push code to your new repository using your old username. Add you new username explicitly to the URL:
git remote set-url origin https://user_name#github.com/user_name/project_name.git
Or use the SSH syntax:
git remote set-url origin user_name#github.com:user_name/project_name.git
Question :
$ git push -u origin main
remote: Permission to username/project_name.git denied to another_username
fatal: unable to access 'https://github.com/user_name/project_name.git/': The requested URL returned error: 403
Answer :
Above the Setting icon in visual studio code there will be a Account Sign in logo icon, click and check it is login with another account or not ?
If it is log in with another Account you will be get the same error continuously... So,
The solution is : You should sign out the other Account in the visual studio and then try in visual studio code terminal following code given below...
$ git push
Then it will ask username and password
you should enter the correct details and it will work perfectly.
Just see the same problem and here is my solution:
Before we generate the token. We need to enable some elements of "select scopes in github settings as show below.
I just select several elements and generate key. Therefore I can push the code after fill username and password(generated key).
Check what configuration helper you do have: it might have cached the wrong credentials (from the old users).
git config --global credential helper
Adjust you PATH to use said credential helper.
If you are on Windows, in a CMD, set a simplified PATH like:
set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set "GH=%ProgramFiles%\Git"
set "PATH=%GH%\bin;%GH%\cmd;%GH%\usr\bin;%GH%\mingw64\bin;%GH%\mingw64\libexec\git-core;%PATH%"
Then type in the same CMD:
printf "Host=bitbucket.org\nprotocol=https\nusername=old_username" | git credential-manager-core erase
Replace:
manager-core by your actual credential helper, as returned by git config --global credential helper
old_username by the old username GitHub account
Then try again.
First check your credentials:
git config --global user.name
git config --global user.email
Then change with:
git config --global user.name "email"
git config --global user.email "email#email.com"
If you set another credential before, will have problem
use git config credential.username "username"
I'm getting the following error when I pull or push code from GIT.
Failed (SignatureException) to execute: Signature encoding error
It took a while to find a simple solution.
You can try either one of the following:
Solution 1:
go to your ssh folder (cd ~/.ssh/)
check if you have a config file or else create one file with the name config and copy the below details.
Host github.foo.com
Hostname github.foo.com
User git
Port 22
IdentityFile ~/.ssh/your_private_key
HostKeyAlgorithms ^rsa-sha2-512,rsa-sha2-256,ssh-rsa
(Replace the hostname and the path to the key as appropriate.)
In my case, I'm trying to access the IBM GitHub repository. and my private key file name is id_rsa
Example:
Host github.ibm.com
Hostname github.ibm.com
User git
Port 22
IdentityFile ~/.ssh/id_rsa
HostKeyAlgorithms ^rsa-sha2-512,rsa-sha2-256,ssh-rsa
Solution 2:
go to your ssh folder (cd ~/.ssh/)
Back up your known_hosts file in some other location (or rename it. for example: in the above screenshot, I changed it to known_hosts_1), and delete it.
Now try to git pull or push from the EGit.
Solution 3:
If Solution 1: and Solution 2: does not work individually try both solutions together. i.e create a config file and also delete/rename known_hosts file.
More detailed discussion is on:
https://www.eclipse.org/forums/index.php?t=msg&th=1108282/
I faced same problem and I resolved this by upgrading eGit to version "Git integration for Eclipse 6.4.0.202211300538-r"
So after installing the Github plugin to Jenkins CI and attempting to add a job for my Github project to compile automatically after a Github push to master, Jenkins reports that .git/config doesn't exist.
I went to /var/lib/jenkins and created .git and the config file and chowned them to jenkins:nogroup.
The error persisted. I then went and did this in my own VPS home directory. Error persists.
I then made a home folder for the jenkins user with no shell and did the same steps. Error persists.
Which .git/config is it referring to?!
Edit:
The actual error I'm referring to is:
Failed to connect to repository : Command "git config --local credential.helper store --file=\"/tmp/git7406572387997126825.credentials\"" returned status code 255:
stdout:
stderr: error: could not lock config file .git/config: No such file or directory
Solved...switched to SSH.
Steps:
Assume control of Jenkins user. su jenkins
(You may need to set a password for it first (make it good!) sudo passwd jenkins.
Go home: cd ~.
Generate key: ssh keygen -t rsa -C "email". (No passcode)
Copy $JENKINS_HOME/.ssh/id_rsa.pub to Github.
Set Jenkins credentials to authenticate to Github using the private key.
Works fine.
Found a neat workaround here: https://groups.google.com/forum/#!topic/git-users/pyv6ldFxUio
mkdir ~/.git
git config --global user.email "m...#school.com"
https://groups.google.com/forum/#!topic/git-users/pyv6ldFxUio
I followed everything in the GitHub tutorial: https://help.github.com/articles/generating-ssh-keys
I did all the commands in the directory of my repository.
I reached the end of tutorial successfully and got the message: "Hi username! You've successfully authenticated, but GitHub does not # provide shell access."
However when I tried to do things such as push it still requested for my username and password.
Check your remotes via git remote -v.
https:// URLs will always ask for a password, unless you configure a credential helper. More info on that in this question.
The simplest solution for password-less git access would be to use the git remote set-url command and set an SSH url for the existing repo.
In your case, git remote set-url origin git#github.com:name/repo.
Then you should be able to git push origin <branch> without being asked for a password.
Good that you have correctly setup your git ssh now you need to reclone the git repository with ssh for example previously you would have done something like this :
git clone https://github.com/dangrossman/bootstrap-daterangepicker.git
this was a https clone now you need to clone with ssh as
git clone git#github.com:dangrossman/bootstrap-daterangepicker.git
you can find the ssh link from your github account same place where you found your https link.
After this you can easily push without your password prompt .
It might though ask for your ssh unlock password. You then need to enter the paraphase you gave during the creation of your ssh key . If you left it blank it might not prompt for it .
I was able to stop the username & password prompt by opening .git/config from the base repo directory and changing the remote URL.
For example:
[remote "origin"]
url = https://github.com/username/my-repo.git
should be changed to:
[remote "origin"]
url = git#github.com:username/my-repo.git
I tried the answer marked as correct but couldn't make it work. This worked for me instead git remote set-url origin ssh://git#github.com/username/reponame
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/amalapk/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