I want to add a file into github as follow:
git init
touch test.txt
git add test.tst
git cmmit -m'testtest'
git push origin master
then it will raise this exception:
error: The requested URL returned error: 403 while accessing https://github.com/yacheng1127/YWProject.git/info/refs
fatal: HTTP request failed
then I verify the public key is attached to my github account:
$ ssh -T git#github.com
Hi yacheng1127! You've successfully authenticated, but GitHub does not provide shell access.
$ ssh-add -l
2048 1a:a1:33:26:21:68:7e:9c:26:19:fb:74:a4:d1:6b:bd yacheng1127#gmail.com (RSA)
then I check my remote url:
$ git remote -vorigin
origin https://github.com/yacheng1127/YWProject.git (fetch)
origin https://github.com/yacheng1127/YWProject.git (push)
I don't know where is the problem. could somebody help me? thank you
Use ssh key is used when you use the "git://" url for your remote, you can change this (https://help.github.com/articles/changing-a-remote-s-url).
But "https://" should work too (read/write), but it can't use your ssh key nor ssh agent, you should give git your github login and password :
https://help.github.com/articles/set-up-git#password-caching
Related
When I try to push my files to the git server I faced this problem.
`~ git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
So, I've entered git push --set-upstream origin main in the terminal. It was showing up the following error.
ERROR: Permission to adivenkat05/C-Assignments.git denied to deploy key
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
So, after searching for the solution, it was that we need to upload our ssh key in the git server (Deploy Key).
I've uploaded that same key to another repository but it ended up showing me this "So, after searching for the solution, it was that we need to upload our ssh key in the git server (Deploy Key).
I've uploaded that same key to another repository but it ended up showing me this "Key is already in use".
So, it's not possible to have multiple ssh keys in a particular machine, right?
How do I tackle this problem?".
The second error is different, and refer to an authentication problem.
You can have multiple keys, a deploy one and one associated with your user account.
Create a new dedicated key, and add it to your account:
ssh-keygen -t rsa -P "" -f ~/.ssh/me
Reference it in a ~/.ssh/config file:
Host gh
Hostname github.com
User git
IdentityFile ~/.ssh/me
IdentitiesOnly yes
And your SSH URL becomes gh:me/myRepository. (no more git#github.com:...)
You can test your SSH key with ssh -Tv gh.
It it works:
cd /path/to/my/local/repo
git remote set-url origin gh:adivenkat05/C-Assignments.git
git push -u origin main
OS: Mac Mojave
I have a personal GitHub account that I contribute to, and some other corporate accounts that I contribute to as well.
On my private account, I created a private repo, and what I would like to do, is check some source code, that I have on my local disk, into that repository.
From a Mac terminal, I made sure I was in the directory I wanted to check into the empty private repo, and then I did the following:
git init
git add .
git commit -m "checking existing files into my private repo"
I then went to my private repo, and copied the URL, let's say:
https://github.com/myaccount/myPrivateRepo
I then did the following:
git remote add origin https://github.com/myaccount/myPrivateRepo
and then did:
git remote -v
And got the following response:
origin https://github.com/myaccount/myPrivateRepo (fetch)
origin https://github.com/myaccount/myPrivateRepo (push)
Which I assumed means: everything checks out OK
Then I tried to push, using:
git push -u origin master
Which gave me the following error message:
remote: Repository not found.
fatal: repository 'https://github.com/myaccount/myPrivateRepo/' not found
Any ideas?
I trued changing the remote to:
git remote add origin git#github.com:myaccount/myPrivateRepo.git
and when I tried to push, I got the following error:
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
The remote you add should be of this form:
git#github.com:myaccount/myPrivateRepo.git
Also set your git email address to match those of your github account:
git config user.email "you#example.com"
git config user.name "Full Name"
You can also edit these by editing the .git/config file.
Finally, make sure your SSH public key is correctly set up:
https://github.com/settings/keys
Your public key should be located in cat ~/.ssh/id_rsa.pub. You can print it with:
cat ~/.ssh/id_rsa.pub
If you don't have an SSH public key yet, then follow this guide:
https://help.github.com/en/articles/connecting-to-github-with-ssh
I created ssh key as per this tutorial.
Assigned it to the ssh-agent.
Added it to the github account as per this tutorial.
ssh-add -l -E md5
Shows correct footprint
ssh -T git#github.com
Says:
Hi <My username>! You've successfully authenticated, but GitHub does not provide shell access.
But still:
git push
Asks for:
Username for 'https://github.com':
Any idea? Thanks in advance.
Check out this: switching-remote-urls-from-https-to-ssh
High are the changes that you clone your repo over HTTPS and now want to push using SSH.
As suggested on the GitHub site check your remote origin by doing this:
$ git remote -v
origin https://github.com/USERNAME/REPOSITORY.git (fetch)
origin https://github.com/USERNAME/REPOSITORY.git (push)
In case you have https... change it to ssh by doing something like this:
git remote set-url origin git#github.com:USERNAME/REPOSITORY.git
I have the repo here Link to the repo
I cloned it and did some changes but when I try to push it.
It gives me the following error:
$ git push origin HEAD:refs/for/master
Username for 'https://review.gerrithub.io': ardyflora
Password for 'https://ardyflora#review.gerrithub.io':
fatal: Authentication failed for
'https://review.gerrithub.io/ardyflora/virginPulseAuto/'
I have even added the ssh key. Any pointer or help will be appreciated :)
Authentication failure for HTTPS. Better you can take a try with SSH.
Copy the URL for SSH of your repository using a browser and update your local origin.
$ git remote set-url origin <ssh-clone-url>
$ git push origin HEAD:refs/for/master
I am trying to push a project (Calico) to GitHub, and am running into an error. I've successfully logged in via a ssh connection, and received the usual response:
Ryan#RYANLAPTOP-PC /C/inetpub/wwwroot/Calico (master)
$ ssh git#github.com
Enter passphrase for key '/c/Users/Ryan/.ssh/id_rsa':
Hi rossryan! You've successfully authenticated, but GitHub does not provide shel
l access.
Connection to github.com closed.
However, I am still receiving an error when I attempt to push the code:
Ryan#RYANLAPTOP-PC /C/inetpub/wwwroot/Calico (master)
$ git push -u github master
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
Connection abandoned.
fatal: The remote end hung up unexpectedly
I believe I've followed the instructions rather faithfully from the website, substituting 'GitHub' for 'origin' in the right areas (origin is apparently already defined, so I used a different name). I've emailed GitHub about this problem, but have received no response.
Does anyone have any other ideas?
EDIT:
Output from git remote -v:
Ryan#RYANLAPTOP-PC /C/inetpub/wwwroot/Calico (master)
$ git remote -v
github git#github.com:rossryan/Calico.git (fetch)
github git#github.com:rossryan/Calico.git (push)
origin C:/inetpub/wwwroot/Calico/ (fetch)
origin C:/inetpub/wwwroot/Calico/ (push)
git push origin master fails was about that error when using putty (instead of the packaged openssh included with msysgit). I don't think that is your case.
git - Server host key not cached is about that same error, and proposes to establish an ssh connection, which you did (and it didn't propose to add github to your $HOME/ssh/known_hosts file, so this isn't the issue either.
What you need to check is:
why are you pushing to github instead of the default name 'origin' (did you really add a remote (upstream) repo named 'github'?)
What exact address is behind the remote name 'github'. A right address for pushing would be (from GitHub man page on remote):
an ssh URL git#github.com:user/repo.git
or an https URL such like https://user#github.com/user/repo.git