how to set up username and passwords for different git repos?
─[$] cat ~/.gitconfig
[user]
name = Shirish Agarwal
email = xxxx@xxxx.xxx
[core]
editor = leafpad
excludesfiles = /home/shirish/.gitignore
gitproxy = "ssh" for gitorious.org
[merge]
tool = meld
[push]
default = simple
[color]
ui = true
status = auto
branch = auto
Now I want to put my git credentials for github, gitlab and gitorious so each time I do not have to lookup the credentials on the browser. How can this be done so it's automated ?
I am running zsh
password git
add a comment |
─[$] cat ~/.gitconfig
[user]
name = Shirish Agarwal
email = xxxx@xxxx.xxx
[core]
editor = leafpad
excludesfiles = /home/shirish/.gitignore
gitproxy = "ssh" for gitorious.org
[merge]
tool = meld
[push]
default = simple
[color]
ui = true
status = auto
branch = auto
Now I want to put my git credentials for github, gitlab and gitorious so each time I do not have to lookup the credentials on the browser. How can this be done so it's automated ?
I am running zsh
password git
What kind of credentials are you using - typically these days you set up ssh?
– icarus
Jan 8 '17 at 5:57
umm... this was from sometime ago, so maybe ssh isn't setup, I'm not sure.
– shirish
Jan 8 '17 at 8:12
This is not Unix/Linux specific, should have sent it to SuperUser or SO... but whatever :)
– Ondra Žižka
Sep 3 '18 at 19:41
add a comment |
─[$] cat ~/.gitconfig
[user]
name = Shirish Agarwal
email = xxxx@xxxx.xxx
[core]
editor = leafpad
excludesfiles = /home/shirish/.gitignore
gitproxy = "ssh" for gitorious.org
[merge]
tool = meld
[push]
default = simple
[color]
ui = true
status = auto
branch = auto
Now I want to put my git credentials for github, gitlab and gitorious so each time I do not have to lookup the credentials on the browser. How can this be done so it's automated ?
I am running zsh
password git
─[$] cat ~/.gitconfig
[user]
name = Shirish Agarwal
email = xxxx@xxxx.xxx
[core]
editor = leafpad
excludesfiles = /home/shirish/.gitignore
gitproxy = "ssh" for gitorious.org
[merge]
tool = meld
[push]
default = simple
[color]
ui = true
status = auto
branch = auto
Now I want to put my git credentials for github, gitlab and gitorious so each time I do not have to lookup the credentials on the browser. How can this be done so it's automated ?
I am running zsh
password git
password git
edited Jan 8 '17 at 9:48
Stephen Kitt
169k24382458
169k24382458
asked Jan 8 '17 at 2:02
shirishshirish
3,75163083
3,75163083
What kind of credentials are you using - typically these days you set up ssh?
– icarus
Jan 8 '17 at 5:57
umm... this was from sometime ago, so maybe ssh isn't setup, I'm not sure.
– shirish
Jan 8 '17 at 8:12
This is not Unix/Linux specific, should have sent it to SuperUser or SO... but whatever :)
– Ondra Žižka
Sep 3 '18 at 19:41
add a comment |
What kind of credentials are you using - typically these days you set up ssh?
– icarus
Jan 8 '17 at 5:57
umm... this was from sometime ago, so maybe ssh isn't setup, I'm not sure.
– shirish
Jan 8 '17 at 8:12
This is not Unix/Linux specific, should have sent it to SuperUser or SO... but whatever :)
– Ondra Žižka
Sep 3 '18 at 19:41
What kind of credentials are you using - typically these days you set up ssh?
– icarus
Jan 8 '17 at 5:57
What kind of credentials are you using - typically these days you set up ssh?
– icarus
Jan 8 '17 at 5:57
umm... this was from sometime ago, so maybe ssh isn't setup, I'm not sure.
– shirish
Jan 8 '17 at 8:12
umm... this was from sometime ago, so maybe ssh isn't setup, I'm not sure.
– shirish
Jan 8 '17 at 8:12
This is not Unix/Linux specific, should have sent it to SuperUser or SO... but whatever :)
– Ondra Žižka
Sep 3 '18 at 19:41
This is not Unix/Linux specific, should have sent it to SuperUser or SO... but whatever :)
– Ondra Žižka
Sep 3 '18 at 19:41
add a comment |
2 Answers
2
active
oldest
votes
Using SSH
The common approach for handling git authentication is to delegate it to SSH. Typically you set your SSH public key in the remote repository (e.g. on GitHub), and then you use that whenever you need to authenticate. You can use a key agent of course, either handled by your desktop environment or manually with ssh-agent
and ssh-add
.
To avoid having to specify the username, you can configure that in SSH too, in ~/.ssh/config
; for example I have
Host git.opendaylight.org
User skitt
and then I can clone using
git clone ssh://git.opendaylight.org:29418/aaa
(note the absence of a username there).
Using gitcredentials
If the SSH approach doesn't apply (e.g. you're using a repository accessed over HTTPS), git does have its own way of handling credentials, using gitcredentials
(and typically git-credential-store
). You specify your username using
git config credential.${remote}.username yourusername
and the credential helper using
git config credential.helper store
(specify --global
if you want to use this setup everywhere).
Then the first time you access a repository, git will ask for your password, and it will be stored (by default in ~/.git-credentials
). Subsequent accesses to the repository will use the stored password instead of asking you.
1
can you elaborate a bit aboutcredential.${remote}
andcredential.helper
. Is there some documentation you could point out as this is the first time I am reading about it.
– shirish
Jan 8 '17 at 19:14
I linked to the manpages in my answer, that's the documentation.${remote}
is the protocol and hostname part of the URI you want to clone,helper
points to a helper program.
– Stephen Kitt
Jan 8 '17 at 19:22
1
There's also a chapter of Pro Git on the topic.
– Stephen Kitt
Jan 8 '17 at 19:24
add a comment |
For those finding this later -- I had difficulties with this and finally made it work
https / credentials.helper / Ubuntu
- Unset Globally:
git config --global --unset credentials.helper
- Unset locally: (In each repo)
git config --unset credential.helper
Create credential file for each repo: (inside each repo)
git config credential.helper 'store --file ~/.git_reponame_credentials'
Not saying it is the best way or the only way - but it worked for me after several frustrating hours.
seems to be similar to what stephen kitt shared above.
– shirish
May 12 '18 at 15:20
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f335704%2fhow-to-set-up-username-and-passwords-for-different-git-repos%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Using SSH
The common approach for handling git authentication is to delegate it to SSH. Typically you set your SSH public key in the remote repository (e.g. on GitHub), and then you use that whenever you need to authenticate. You can use a key agent of course, either handled by your desktop environment or manually with ssh-agent
and ssh-add
.
To avoid having to specify the username, you can configure that in SSH too, in ~/.ssh/config
; for example I have
Host git.opendaylight.org
User skitt
and then I can clone using
git clone ssh://git.opendaylight.org:29418/aaa
(note the absence of a username there).
Using gitcredentials
If the SSH approach doesn't apply (e.g. you're using a repository accessed over HTTPS), git does have its own way of handling credentials, using gitcredentials
(and typically git-credential-store
). You specify your username using
git config credential.${remote}.username yourusername
and the credential helper using
git config credential.helper store
(specify --global
if you want to use this setup everywhere).
Then the first time you access a repository, git will ask for your password, and it will be stored (by default in ~/.git-credentials
). Subsequent accesses to the repository will use the stored password instead of asking you.
1
can you elaborate a bit aboutcredential.${remote}
andcredential.helper
. Is there some documentation you could point out as this is the first time I am reading about it.
– shirish
Jan 8 '17 at 19:14
I linked to the manpages in my answer, that's the documentation.${remote}
is the protocol and hostname part of the URI you want to clone,helper
points to a helper program.
– Stephen Kitt
Jan 8 '17 at 19:22
1
There's also a chapter of Pro Git on the topic.
– Stephen Kitt
Jan 8 '17 at 19:24
add a comment |
Using SSH
The common approach for handling git authentication is to delegate it to SSH. Typically you set your SSH public key in the remote repository (e.g. on GitHub), and then you use that whenever you need to authenticate. You can use a key agent of course, either handled by your desktop environment or manually with ssh-agent
and ssh-add
.
To avoid having to specify the username, you can configure that in SSH too, in ~/.ssh/config
; for example I have
Host git.opendaylight.org
User skitt
and then I can clone using
git clone ssh://git.opendaylight.org:29418/aaa
(note the absence of a username there).
Using gitcredentials
If the SSH approach doesn't apply (e.g. you're using a repository accessed over HTTPS), git does have its own way of handling credentials, using gitcredentials
(and typically git-credential-store
). You specify your username using
git config credential.${remote}.username yourusername
and the credential helper using
git config credential.helper store
(specify --global
if you want to use this setup everywhere).
Then the first time you access a repository, git will ask for your password, and it will be stored (by default in ~/.git-credentials
). Subsequent accesses to the repository will use the stored password instead of asking you.
1
can you elaborate a bit aboutcredential.${remote}
andcredential.helper
. Is there some documentation you could point out as this is the first time I am reading about it.
– shirish
Jan 8 '17 at 19:14
I linked to the manpages in my answer, that's the documentation.${remote}
is the protocol and hostname part of the URI you want to clone,helper
points to a helper program.
– Stephen Kitt
Jan 8 '17 at 19:22
1
There's also a chapter of Pro Git on the topic.
– Stephen Kitt
Jan 8 '17 at 19:24
add a comment |
Using SSH
The common approach for handling git authentication is to delegate it to SSH. Typically you set your SSH public key in the remote repository (e.g. on GitHub), and then you use that whenever you need to authenticate. You can use a key agent of course, either handled by your desktop environment or manually with ssh-agent
and ssh-add
.
To avoid having to specify the username, you can configure that in SSH too, in ~/.ssh/config
; for example I have
Host git.opendaylight.org
User skitt
and then I can clone using
git clone ssh://git.opendaylight.org:29418/aaa
(note the absence of a username there).
Using gitcredentials
If the SSH approach doesn't apply (e.g. you're using a repository accessed over HTTPS), git does have its own way of handling credentials, using gitcredentials
(and typically git-credential-store
). You specify your username using
git config credential.${remote}.username yourusername
and the credential helper using
git config credential.helper store
(specify --global
if you want to use this setup everywhere).
Then the first time you access a repository, git will ask for your password, and it will be stored (by default in ~/.git-credentials
). Subsequent accesses to the repository will use the stored password instead of asking you.
Using SSH
The common approach for handling git authentication is to delegate it to SSH. Typically you set your SSH public key in the remote repository (e.g. on GitHub), and then you use that whenever you need to authenticate. You can use a key agent of course, either handled by your desktop environment or manually with ssh-agent
and ssh-add
.
To avoid having to specify the username, you can configure that in SSH too, in ~/.ssh/config
; for example I have
Host git.opendaylight.org
User skitt
and then I can clone using
git clone ssh://git.opendaylight.org:29418/aaa
(note the absence of a username there).
Using gitcredentials
If the SSH approach doesn't apply (e.g. you're using a repository accessed over HTTPS), git does have its own way of handling credentials, using gitcredentials
(and typically git-credential-store
). You specify your username using
git config credential.${remote}.username yourusername
and the credential helper using
git config credential.helper store
(specify --global
if you want to use this setup everywhere).
Then the first time you access a repository, git will ask for your password, and it will be stored (by default in ~/.git-credentials
). Subsequent accesses to the repository will use the stored password instead of asking you.
answered Jan 8 '17 at 10:07
Stephen KittStephen Kitt
169k24382458
169k24382458
1
can you elaborate a bit aboutcredential.${remote}
andcredential.helper
. Is there some documentation you could point out as this is the first time I am reading about it.
– shirish
Jan 8 '17 at 19:14
I linked to the manpages in my answer, that's the documentation.${remote}
is the protocol and hostname part of the URI you want to clone,helper
points to a helper program.
– Stephen Kitt
Jan 8 '17 at 19:22
1
There's also a chapter of Pro Git on the topic.
– Stephen Kitt
Jan 8 '17 at 19:24
add a comment |
1
can you elaborate a bit aboutcredential.${remote}
andcredential.helper
. Is there some documentation you could point out as this is the first time I am reading about it.
– shirish
Jan 8 '17 at 19:14
I linked to the manpages in my answer, that's the documentation.${remote}
is the protocol and hostname part of the URI you want to clone,helper
points to a helper program.
– Stephen Kitt
Jan 8 '17 at 19:22
1
There's also a chapter of Pro Git on the topic.
– Stephen Kitt
Jan 8 '17 at 19:24
1
1
can you elaborate a bit about
credential.${remote}
and credential.helper
. Is there some documentation you could point out as this is the first time I am reading about it.– shirish
Jan 8 '17 at 19:14
can you elaborate a bit about
credential.${remote}
and credential.helper
. Is there some documentation you could point out as this is the first time I am reading about it.– shirish
Jan 8 '17 at 19:14
I linked to the manpages in my answer, that's the documentation.
${remote}
is the protocol and hostname part of the URI you want to clone, helper
points to a helper program.– Stephen Kitt
Jan 8 '17 at 19:22
I linked to the manpages in my answer, that's the documentation.
${remote}
is the protocol and hostname part of the URI you want to clone, helper
points to a helper program.– Stephen Kitt
Jan 8 '17 at 19:22
1
1
There's also a chapter of Pro Git on the topic.
– Stephen Kitt
Jan 8 '17 at 19:24
There's also a chapter of Pro Git on the topic.
– Stephen Kitt
Jan 8 '17 at 19:24
add a comment |
For those finding this later -- I had difficulties with this and finally made it work
https / credentials.helper / Ubuntu
- Unset Globally:
git config --global --unset credentials.helper
- Unset locally: (In each repo)
git config --unset credential.helper
Create credential file for each repo: (inside each repo)
git config credential.helper 'store --file ~/.git_reponame_credentials'
Not saying it is the best way or the only way - but it worked for me after several frustrating hours.
seems to be similar to what stephen kitt shared above.
– shirish
May 12 '18 at 15:20
add a comment |
For those finding this later -- I had difficulties with this and finally made it work
https / credentials.helper / Ubuntu
- Unset Globally:
git config --global --unset credentials.helper
- Unset locally: (In each repo)
git config --unset credential.helper
Create credential file for each repo: (inside each repo)
git config credential.helper 'store --file ~/.git_reponame_credentials'
Not saying it is the best way or the only way - but it worked for me after several frustrating hours.
seems to be similar to what stephen kitt shared above.
– shirish
May 12 '18 at 15:20
add a comment |
For those finding this later -- I had difficulties with this and finally made it work
https / credentials.helper / Ubuntu
- Unset Globally:
git config --global --unset credentials.helper
- Unset locally: (In each repo)
git config --unset credential.helper
Create credential file for each repo: (inside each repo)
git config credential.helper 'store --file ~/.git_reponame_credentials'
Not saying it is the best way or the only way - but it worked for me after several frustrating hours.
For those finding this later -- I had difficulties with this and finally made it work
https / credentials.helper / Ubuntu
- Unset Globally:
git config --global --unset credentials.helper
- Unset locally: (In each repo)
git config --unset credential.helper
Create credential file for each repo: (inside each repo)
git config credential.helper 'store --file ~/.git_reponame_credentials'
Not saying it is the best way or the only way - but it worked for me after several frustrating hours.
edited Sep 3 '18 at 19:39
Ondra Žižka
454312
454312
answered May 11 '18 at 17:48
SteveJSteveJ
1164
1164
seems to be similar to what stephen kitt shared above.
– shirish
May 12 '18 at 15:20
add a comment |
seems to be similar to what stephen kitt shared above.
– shirish
May 12 '18 at 15:20
seems to be similar to what stephen kitt shared above.
– shirish
May 12 '18 at 15:20
seems to be similar to what stephen kitt shared above.
– shirish
May 12 '18 at 15:20
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f335704%2fhow-to-set-up-username-and-passwords-for-different-git-repos%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What kind of credentials are you using - typically these days you set up ssh?
– icarus
Jan 8 '17 at 5:57
umm... this was from sometime ago, so maybe ssh isn't setup, I'm not sure.
– shirish
Jan 8 '17 at 8:12
This is not Unix/Linux specific, should have sent it to SuperUser or SO... but whatever :)
– Ondra Žižka
Sep 3 '18 at 19:41