Using different credentials for alternating repos with Microsoft Git-Credential-Manager
Asked Answered
M

1

1

I'm using Microsoft Git-Credential-Manager for Linux (Ubuntu) for a couple weeks, with some credentials, and now I need to push modifications to a different repo with different credentials. But I can't do this, because GCM is trying to use incorrect data to access this repository.

How do I change these or add new ones in order to be able to commit to different repos with different credentials? Is it possible?

Microelement answered 4/3, 2020 at 22:44 Comment(0)
D
1

You can use git credential manager command to delete the entry for a given remote host.

git credential-manager reject <url>

Once the entry is deleted, you would be able to store new credentials.

You can store (git credential-manager store) one credential per host and user: that will be valid for all repos owned by said user.

For a credential per repository, as seen in Git-Credential-Manager-for-Windows/issue 749, use (for Windows or Linux) the git config credential.useHttpPath, explained in git credentials.

 git config --global credential.useHttpPath true
Detrude answered 5/3, 2020 at 6:59 Comment(4)
Thanks for your answer. So isn't there a way to store more than one credential, like one per repo? Basically, I'll need to remove the old credentials every time I need to push to a different repository?Microelement
@Microelement You can, with git credential-manager store, as seen in github.com/microsoft/Git-Credential-Manager-for-Windows/issues/… put one credential per host, and per user. Just make sure your remote URL to which you are pushing includes the username https::/[email protected]/username/myRepo.gitDetrude
@Microelement It should: the idea is the API (store/reject/approve/...) remains the same for any implementation of a git credential-manager command.Detrude
@Microelement You can also have one credential per repo, as seen in my edited answer. But I would still recommend to stick with one credential per user and server hostname.Detrude

© 2022 - 2024 — McMap. All rights reserved.