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?

sb813322
  • 129
  • 9
darksoulsong
  • 13,988
  • 14
  • 47
  • 90

1 Answers1

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 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? – darksoulsong Mar 05 '20 at 11:52
  • @darksoulsong You can, with `git credential-manager store`, as seen in https://github.com/microsoft/Git-Credential-Manager-for-Windows/issues/888 put one credential per host, ***and per user***. Just make sure your remote URL to which you are pushing includes the username `https::/username@github.com/username/myRepo.git` – VonC Mar 05 '20 at 11:58
  • @darksoulsong It should: the idea is the API (store/reject/approve/...) remains the same for any implementation of a `git credential-manager` command. – VonC Mar 05 '20 at 12:01
  • @darksoulsong 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. – VonC Mar 05 '20 at 12:38