克隆 gitlab 项目,一直使用 git lfs 不提供密码 [英] Clone gitlab project that uses git lfs without giving password all the time

查看:24
本文介绍了克隆 gitlab 项目,一直使用 git lfs 不提供密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定在 gitlab 上尝试 git lfs.我注意到它不适用于 ssh,所以我决定使用 https.Push 工作得很好,但是当我尝试克隆我的项目时,它要求我为 每个 文件输入用户名和密码.

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 asked me for a username and a password for every file.

这有点烦人.有什么解决办法吗?

That's kind of annoying. Is there any workaround to it?

这个问题一直存在,真正的解决方案在哪里?有简单直接的配方吗?

This problem persist, where the real solution? There are a simple and direct recipe for it?

链接 https://git-scm.com/docs/gitcredentialsgit-lfs/wiki/Tutorial 可能有一些东西,但没有客观的解决方案.

The links https://git-scm.com/docs/gitcredentials and git-lfs/wiki/Tutorial have perhaps something, but no objective solution.

我的git lfs env描述的情况,

git-lfs/2.4.0 (GitHub; linux amd64; go 1.8.3)
git version 2.7.4

LocalWorkingDir=
LocalGitDir=
LocalGitStorageDir=
LocalMediaDir=lfs/objects
LocalReferenceDir=
TempDir=lfs/tmp
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic
UploadTransfers=basic
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"

当我执行 git clone https://github.com/myPrivate/project1 时,问题克隆过程不完整(错误),并且是 一直给用户名和密码...

and when I do git clone https://github.com/myPrivate/project1 the problem clonning process is not complete (bug), and was giving usernae and password all the time...

尝试执行凭据时也会出现问题(请参阅 issue #2223等)

Problems also when try to do credentials (see issue #2223, etc.)

试用报告:

  • git config credential.helper 什么都不输出,空消息.

  • git config credential.helper outputs nothing, empty message.

git config -f .lfsconfig lfs.url https://github.com/myPrivate/MyProj1 接受任何东西......所以,浏览器 URL 或 .git URL?
在它之后的命令 git add .lfsconfig"fatal: Not a git repository (or any parent directory): .git" 在这两种情况下(带有或不带有 .git 的 URL)

git config -f .lfsconfig lfs.url https://github.com/myPrivate/MyProj1 accepts anything... So, is the browser URL or .git URL?
After it the command git add .lfsconfig say "fatal: Not a git repository (or any of the parent directories): .git" in both cases (URL with or without .git)

git config credential.https://github.com/myPrivate/MyProj1 myusername致命:不在 git 目录中",但当然,我需要先克隆(!)..

git config credential.https://github.com/myPrivate/MyProj1 myusername say "fatal: not in a git directory", but of course, I need to clone first (!)..

...

推荐答案

git-lfs 问题 993:

因为 LFS 服务器和 git 服务器可以是不同的端点,所以有可能用户对 git 服务器有权限,但对 LFS 服务器没有权限.

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.

在这种情况下,如果安装了凭据管理器,则不会重置凭据,LFS 将在每​​个后续请求中使用它们,而不会使它们失效.

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.

你应该检查你的 git config credential.helper 输出.
在 Windows 上,它应该是(最近的 2017-2018 Git 版本)经理".
打开 Windows 凭据管理器并清除或修复任何 GitHub 凭据条目.

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.

注意:issue 2349 指出 Git-LFS 有由于 缺少 pty/tty,但这可能已经修复.

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.

(合并答案和评论)

  1. 检查git --version,如果小于2.16,最好安装为此处使用 PPA 的说明

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

检查你的 git config credential.helper 输出,如果为空,
执行这一行:git config --global credential.helper/usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
... 他们再次检查您的 git config credential.helper 输出:需要这样 <代码>/usr/... 路径.

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.1.(如评论)首先执行:git ls-remote https://github.com/myPrivate/MyProj1... 这应该会提示您输入 GitHub 用户名和密码帐户.重复该命令以检查第二次,它不会提示您输入任何内容.

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.做你通常的 git clone (小心地用 sudo rm -r oldBrokenBadClone 删除损坏的旧文件)... 给用户名和密码一次.

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

关于在许多 UBUNTU LTS 服务器中进行测试的最后说明...有时,当您在此过程之前进行克隆时,您无法解决问题(git pull 错误,例如git-credential-libsecret:未找到").解决方案是删除所有旧的克隆仓库(注意 rm -rf).看起来你可以随时做 git config --global credential.helper ,所以,去做吧.再次克隆 - 可能提供两次用户名和密码,但之后就可以了.

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.

这篇关于克隆 gitlab 项目,一直使用 git lfs 不提供密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆