Skip to contentSkip to conversation

How can I append authentication with "git push" ?

DISCUSSION J. Bakshi 5 participants 7 messages Jun 15, 2016

lore
Share & tools
lore

J. Bakshi

author
#0 lore raw

Dear list,

Is there any option to add user-name and password with git push ? Or any repo wise configuration file where I can save the info, so that it doesn't ask the credential before every push ?

Thanks

#1 lore raw
Quoted 1 line · J. Bakshi

Is there any option to add user-name and password with git push ?

The username can go in the URL. For example:

git push user@host:repo.git

for ssh, or:

git push https://user@host/repo.git

for http.

For ssh, you can't specify a password automatically, but you should look into using key authentication (which can then be cached by ssh-agent). For http, you can put the password in the URL, but there are some security implications (like the fact that your password will be cleartext on disk, and visible in the process list to other users on the system).

What protocol are you using to push?

Quoted 2 lines

Or any repo wise configuration file where I can save the info, so that it doesn't ask the credential before every push ?

Older versions of git can read from .netrc, but I would not recommend that, as it involves storing the password in plaintext on disk.

Newer versions of git (v1.7.9 and up) support "credential helpers" which will read from a password wallet or other secure storage provided by the OS. There is a helper for OS X Keychain in contrib/, and somebody has been working on one for Windows. What platform are you using?

-Peff

author
#2 lore raw
In reply to J. Bakshi

Any idea please ?

Quoted 8 lines · On Thu, 12 Jul 2012 13:48:44 +0530 "J. Bakshi"…

Dear list,

Is there any option to add user-name and password with git push ? Or any repo wise configuration file where I can save the info, so that it doesn't ask the credential before every push ?

Thanks

#4 lore raw
In reply to J. Bakshi
Quoted 3 lines · J. Bakshi

Or any repo wise configuration file where I can save the info, so that it doesn't ask the credential before every push ?

I'd like to know how to do that too.

It's a pain to have to type username and password every time I need to push to github. (Linux here btw).

#5 lore raw

Hi,

Quoted 9 lines · Thiago Farina
Quoted 3 lines · J. Bakshi

Or any repo wise configuration file where I can save the info, so that it doesn't ask the credential before every push ?

I'd like to know how to do that too.

It's a pain to have to type username and password every time I need to push to github. (Linux here btw).

If you're specifically looking at GitHub and HTTP auth, take a look at the hub tool:

https://github.com/defunkt/hub

Kind regards,

Nick Douma

#6 lore raw
In reply to Thiago Farina
Quoted 9 lines · Thiago Farina
Quoted 3 lines · J. Bakshi

Or any repo wise configuration file where I can save the info, so that it doesn't ask the credential before every push ?

I'd like to know how to do that too.

It's a pain to have to type username and password every time I need to push to github. (Linux here btw).

I never type either when pushing to github, and I've been pushing there at least twice a day for quite some time (Linux here btw).

I have these in .git/config:

[remote "github2"]
url = https://github.com/git/git
fetch = +refs/heads/*:refs/remotes/github2/* pushurl = github.com:git/git.git push = refs/heads/maint:refs/heads/maint push = refs/heads/master:refs/heads/master push = refs/heads/next:refs/heads/next push = +refs/heads/pu:refs/heads/pu

[remote "github"]
url = https://github.com/gitster/git
pushurl = github.com:gitster/git.git mirror

and then this in $HOME/.ssh/config:

Host github.com
User git
IdentityFile ~/.ssh/github