I git push
my work to a remote Git repository.
Every push
will prompt me to input username
and password
. I would
If you already have your SSH keys set up and are still getting the password prompt, make sure your repo URL is in the form
git+ssh://git@github.com/username/reponame.git
as opposed to
https://github.com/username/reponame.git
To see your repo URL, run:
git remote show origin
You can change the URL with git remote set-url
like so:
git remote set-url origin git+ssh://git@github.com/username/reponame.git
Step 1 -
Create SSH keys on your linux system using below command
ssh-keygen -t rsa -b 4096 -C "your_email"
It will ask for passphrase and file name (default will be ~/.ssh/id_rsa, ~/.ssh/id_rsa.pub)
Step 2 -
Once files created add public key id_rsa.pub to github account ssh section.
Step 3 -
On your machine add private key id_rsa to ssh-agent using below command
ssh-add ~/.ssh/id_rsa
Step 4 -
Now add remote url git@github.com:user_name/repo_name.git to your local git repo using below command.
git remote remove origin
git remote add origin git@github.com:user_name/repo_name.git
Thats it.
Open terminal to create ssh keys:
cd ~ #Your home directory
ssh-keygen -t rsa #Press enter for all values
(Only works if the commit program is capable of using certificates/private & public ssh keys)
Here is a walkthrough on putty gen for the above steps
This step varies, depending on how your remote is set up.
If it is a GitHub repository and you have administrative privileges, go to settings and click 'add SSH key'. Copy the contents of your ~/.ssh/id_rsa.pub
into the field labeled 'Key'.
If your repository is administered by somebody else, give the administrator your id_rsa.pub
.
If your remote repository is administered by your, you can use this command for example:
scp ~/.ssh/id_rsa.pub YOUR_USER@YOUR_IP:~/.ssh/authorized_keys/id_rsa.pub
If you have done the steps above and are still getting the password prompt, make sure your repo URL is in the form
git+ssh://git@github.com/username/reponame.git
as opposed to
https://github.com/username/reponame.git
To see your repo URL, run:
git remote show origin
You can change the URL with:
git remote set-url origin git+ssh://git@github.com/username/reponame.git
[1] This section incorporates the answer from Eric P
Just use --repo
option for git push command. Like this:
$ git push --repo https://name:password@bitbucket.org/name/repo.git
You have to setup a SSH private key, you can review this page, how to do the setup on Mac, if you are on linux the guide should be almost the same, on Windows you would need tool like MSYS.
Just wanted to point out something about the solution said above several times:
git config credential.helper store
You can use any command that requires a password after this. You don't have to push. (you can also pull for instance) After that, you won't need to type in your username / password again.