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
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
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"
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'm a beginner to GitHub.I need to send a pull request to the master branch.
when i typed the code
git push origin master
It gives me the error
fatal: unable to access
'https://github.com/www-prolificme-com/mahawiki/': The requested URL
returned error: 403
Updated
You mentioned you are trying to pull from git but the command is git push. Anyways, most probably you are getting this error because your repo url is not set locally.
If this is the first time you are sending git request from your system, you might want to setup your username by git config --global user.name "John Doe"
If you have already used git on your system, try checking the git configuration on your system using git config --list command to check whether your repo URL is setup or not.
If the url is not setup run git remote set-url origin https://github.com/www-prolificme-com/mahawiki/
Run git remote -v to verify if your url is setup
git add .
git commit -m "your message"
git push origin master
Remove/Update the saved credentials:
Click Start
Search for 'Credential Manager'
Select 'Windows Credentials Manager' > 'Windows Credentials'
Search for the credentials that you want to remove/update
Click on the credential entry > Click 'Edit' or 'Remove'
your repo is not setting locally
so, you seemed crash message
first
git config --list
to showing your git repo set list
and
git remote set-url origin <your git repo address>
to access git repo and git add . to add your files to git container
git commit -m "your git commit message"
this is your git commit message version or anything possible
git push origin master
finally your files pushing on git repo
it's done!
try it
I got this same problem then I try to this below command.
step 1:
git config --global user.email "user email"
step 2:
git config --global user.name "user name"
After running those commands, you can use this command to push your code:
git push origin master
Even if you set all credentials and other setups in the local machine, you might face this problem.
Currently, GitHub uses 'personal access token' so when or after creating personal access token you must check the Select scopes.
You select all you need and then push again.
It will be pushed successfully.
If nothing working please check if you have checked the below checkboxes while creating token
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