Clone gitlab project that uses git lfs without giving password all the time

前端 未结 3 1825
悲&欢浪女
悲&欢浪女 2021-01-13 05:29

I decided to try git lfs on gitlab. I noticed that it doesn\'t work with ssh so I decided to use https for it. Push works just fine but when I tried to clone my project it a

3条回答
  •  被撕碎了的回忆
    2021-01-13 05:41

    As mentioned in git-lfs issue 993:

    Because the LFS server and the git server can be separate endpoints, it is possible that a user has permission for the git server but not the LFS server.

    In this case, if there is a credential manager installed, the credentials will not be reset, and LFS will use them on each subsequent request without ever invalidating them.

    You should check your git config credential.helper output.
    On Windows, it should be (with recent 2017-2018 Git releases) "manager".
    Open the Windows Credential Manager and clear out or fix any GitHub credential entry.

    Note: issue 2349 points out that Git-LFS had a problem to ask for credentials (in absence of an helper), because of a lack of pty/tty, but that has likely been fixed.


    Transtating to dummies

    (consolidating the answer and the comments)

    1. check git --version, if less tham 2.16, install better as instructions here using PPA

    2. check your git config credential.helper output, if it is empty,
      execute this line: git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
      ... Them check again your git config credential.helper output: need to be this /usr/... path.

    3. Cloning...

      3.1. (as commented) Do first: git ls-remote https://github.com/myPrivate/MyProj1... That should prompt for your GitHub username and password account. Repeat that command to check that the second times, it does not prompt you for anything.

      3.2. Do your usual git clone (with care remove the broken old with sudo rm -r oldBrokenBadClone)... Giving username-and-password once.

    Final notes about tests in many UBUNTU LTS servers... Sometimes, when you cloned before this procedure you can't fix the problem (git pull erros like "git-credential-libsecret: not found"). The solution is to remove all old cloned repo (caution with rm -rf). Seemingly you can do git config --global credential.helper any time, so, do it. Clone again — perhaps giving username-and-password twice but will be fine after it.

提交回复
热议问题