Existing remote github repo not found via command line push - github

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

Related

Messed up with deploy key

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

Authentication failed and unable to link visual studio to git repository

I am trying to set up to build my first website and have been following an online tutorial. When trying to link visual studio and my GitHub repository, this is the message I get:
`
samanthacanela#samanthas-air Canela Street Art % git commit -m "initialized git repository"
[main 3a08e0a] initialized git repository
2 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 about.html
rename homepage.html => home.html (100%)
samanthacanela#samanthas-air Canela Street Art % 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
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
samanthacanela#samanthas-air Canela Street Art % git push --set-upstream origin main
The authenticity of host 'github.com (140.82.112.3)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) 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.
samanthacanela#samanthas-air Canela Street Art %
`
I'm an absolute beginner. What the hell am I doing wrong?
I was following along a tutorial and they lost me.
Based on my understanding, I can see that you may haven't setup the origin remote URI. To fix that issue, you'll need to follow these steps.
Logging into git (If you aren't already)
Run these commands to set your display name and email when pushing:-
$ git config --global user.name "Your name here"
$ git config --global user.email "your_email#example.com"
Using HTTPS access method (recommended)
Using GitHub CLI, you can run $ git auth login and follow the steps to login.
Or if you're using GCM (Git Credential Manager)* refer to this article by GitHub
* GCM is another way to store your credentials securely and connect to GitHub over HTTPS. With GCM, you don't have to manually create and store a personal access token, as GCM manages authentication on your behalf, including 2FA (two-factor authentication).
Using SSH access method
If you clone with SSH, you must generate SSH keys on each computer you use to push or pull from GitHub. For more information, see "Generating a new SSH key."
Setting up your repository
** Make sure to run these commands inside your git environment and not globally.
#Set a new remote
git remote add origin github.com/example/example.git
#Verify new remote
git remote -v
Basically, a common cause for an error after following these steps is cloning using HTTPS method instead of SSH. You can correct this by going to your repository, clicking "Clone or download", then clicking the "Use SSH" button above the URL field and updating the URL of your origin remote like this:
$ git remote set-url origin git#github.com:ex-user/example.git
And that forces the source to be SSH.
If this still gives you an error, please refer to this answer.
For more help, refer to this document.

Github deploy keys - permission denied on cloning

I try to clone a private organization github repo onto a server instance, running debian. I try to avoid putting in my private SSH keys, because if they would get leaked, someone would have access to all of my repositories.
Hence I found the way of using deploy keys for private github repos. The way I imagine them to work is the following
create ssh keys on your server
add private key to github repo (under "deploy keys" area)
add config file in ~/.ssh folder on your server
you can git clone the github repository.
Unfortunately, with this setup I am receiving an error that I do not have the correct permissions set.
My config file:
Host github
Hostname github.com
User git
IdentityFile ~/.ssh/MY-REPONAME-gh
When trying to clone via SSH: git clone git#github.com:ORGNAME/MY-REPONAME.git
I receive this error:
Cloning into 'MY-REPONAME'...
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.

can't able to perform git push, permission denied?

I already made a repository in github as wordpress-template.
I created a .git repository locally, added some files there, and committed it.
Then I created a remote as origin and give it the url of the github repository as:
git remote add origin git#github.com:squalporeover/wordpress-template.git
Now I want to push my master branch to that repository. I ran the following command:
git push origin master
But it shows:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
It looks like you added the SSH version of the remote URL. In order to use this you need to set-up Github with SSH.
Otherwise use the HTTPS version of the clone URL which will ask for your username and password:
You need to use ssh-keygen to generate an ssh key pair.
See: https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
Duplicate found here: Git - Permission denied (publickey)
This worked for me:
Step 1- git remote rm origin
Step 2-select the http option in github
step 3- run the following command again
git remote add origin https://github.com/yourdirectory/link.git
git branch -M main
git push -u origin main

The remote end hung up unexpectedly

I installed Git and ran the set up my username and email.
git config --global user.name "Your Name"
git config --global user.email username#gmail.com
Add your public key
Next, I created a project directory called 'projectname' and committed this to a remote Git server.
mkdir projectname
cd projectname
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git#github.com:projectname/projectname.git
git push origin master
My public key has been added to the github website.
When I try to commit I get this error message:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Any suggestions? - I am working with Ruby on Rails
Make sure you copy past the SSH key exactly like it's in the xxxx.pub file do not add lines or spaces to it.
Try again or delete both public and private keys and generate them again. It should work. Also remember to update the pub key again on Github website.
Also test your existing key with this command
ssh -T git#github.com