GitHub: Separate Credentials for Two Windows Accounts

I recently created a second GitHub account that shared my work and my private projects (I used to have only a work account). I use https in conjunction with the Windows credential store. To automatically select the correct account, I save my personal account information in ~/.gitconfigand my work account information in ~/work/.gitconfig, as suggested here .

Unfortunately, when I try to make changes to my private repositories, I get the following error:

$ git push
remote: Permission to privateuser/privaterepo.git denied to workuser.
fatal: unable to access 'https://privateuser@github.com/privateuser/privaterepo.git/': The requested URL returned error: 403

I set the remote url git remote set-url origin https://privateuser@github.com/privateuser/privaterepo.gitlike the one suggested here . Clicking on my repo work is still working fine. And when I type git config user.namein my personal / work repositories, I get my personal / work username, respectively, as it should be.

What is the problem with the new private repositories? Why does git still think that I am workuserwhen I try to click on my personal repositories? Do I need to do something with the Windows credential storage that I used to store my credentials? He never asked for the password of my personal account ...

+7
source share
4 answers

, (user.name/email).

( : /)

, (, linux osx-keychain)
:

git config credential.helper

SSH- , : (github.com)


: GCM (Git ) Git Windows, 363, Uri.

+3

Jenkins, , .

Jenkins AWS CodeCommit . mvn release, Github. jenkins , SSH, HTTPS.

, . , Github MFA, .

# /var/lib/jenkins/.gitconfig
[user]
  name = Jenkins
  email = jenkins@domain.io
[credential]
  helper = !aws --profile default codecommit credential-helper $@
  UseHttpPath = true
[credential "https://github.com"]
  helper = store

# /var/lib/jenkins/.git-credentials
https://username:password@github.com/SomeOrg/some-repo

, , , / Github, git, :

useHttpPath - Git , "" URL- http . , , https://example.com/foo.git, https://example.com/bar.git. , true.

https://git-scm.com/docs/gitcredentials

0

@majikman Could you share a second example without your specific Jenkins? For example, I can’t understand what this line is:

helper = !aws --profile default codecommit credential-helper $@

Thank,

-e

0
source

You can set the user for this repository only by entering:

git config --local user.name 'Full Name'

git config --local user.email 'your@mail.com'

This will not affect other repositories.

-1
source

Source: https://habr.com/ru/post/1692625/


All Articles