3

One password is no problem

I wanted to store my credentials "safely" for use by git so I did as instructed here. This way I don't have to input password/PAT every single time, I perform any git operation.

  1. Install libsecret using sudo apt-get install libsecret-1-0 libsecret-1-dev

  2. Build the "credential manager" using sudo make --directory=/usr/share/doc/git/contrib/credential/libsecret

  3. and then configure my local git folder using git config --global credential.helper \ /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret

Works superb.

How to do the above with many passwords?

What I don't get is how to do the same for many passwords associated with different accounts/repositories. I was suggested to use gcm core.

I tried installing gcm core as instructed here.

  1. Download .deb package

  2. sudo dpkg -i <path-to-package> git-credential-manager-core configure

  3. configure the "credential store" git config credential.credentialStore secretservice (as I use libsecret).

  4. I removed the Credential helper pointing to /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret from the local git config file.

It still doesn't work. When I try to push a repo, I get a garbled message with how to use git config followed by request to fill in credentials (shown here). I don't understand what I am doing! namely credential store, credential manager, secret-service and gcm core.

I looked here and here and I still don't get it.

agent18
  • 2,109
  • 4
  • 20
  • 34

1 Answers1

2

Any credential helper should follow the same process.

But if you have multiple account/password for the same domain (say github.com for instance), then you need to change your remote URL

 cd /path/to/my/local/repo1
 git remote set-url origin https://user1@github.com/user1/myRepo1
                                   ^^^^^^

 cd /path/to/my/local/repo2
 git remote set-url origin https://user2@github.com/user1/myRepo2
                                   ^^^^^^

That way, the credential helper will differentiate your different account.
Since gcm core is a bit fineky to install, test it first with the classic libsecret-based helper.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I tried it, but I still get the same garbled output followed by request to type password (not username though). When I type the password, it doesn't end up saving it. – agent18 May 05 '21 at 17:40
  • What does it mean to "test it first with classic libsecret-based helper"? – agent18 May 05 '21 at 17:41
  • @agent18 The first part of your question, the one ending with "Works superb.": test it with that. – VonC May 05 '21 at 17:46
  • Just did... So the old repo which worked before still continues to work. Here the local git config `credential.helper` points to `libsecret/git-credential-libsecret`. Still works with the same "garbled error" (as shown [here](https://pastebin.com/K1Lqt7tX)) – agent18 May 05 '21 at 17:50
  • @agent18 What version of Git are you using? show-scope is Git 2.26 (Q1 2020): https://stackoverflow.com/a/60286340/6309 – VonC May 05 '21 at 17:53
  • 2.25.1 is the version number. – agent18 May 05 '21 at 17:55
  • Am I using an advanced version of GCM core? – agent18 May 05 '21 at 18:00
  • 1
    @GCM core might be using an option of Git 2.26+. Can you upgrade first Git to 2.31.1? (http://lifeonubuntu.com/upgrading-ubuntu-to-use-the-latest-git-version/) – VonC May 05 '21 at 18:03
  • 1
    Bro Hearty thanks. YOU DID IT. It is because of people like you that I can still use linux albeit strugglingly. IT WORKS. I needed two things: 1 is `git remote set-url origin https://user1@github.com/user1/myRepo1.git` and the other is `git 2.31`. This seems to have done the trick... for both my usernames. I will update the answers. :) THANKS A TON. – agent18 May 05 '21 at 18:25