克隆 gitlab 项目,该项目使用 git lfs 而无需一直提供密码
Clone gitlab project that uses git lfs without giving password all the time
我决定在 gitlab 上尝试 git lfs。我注意到它不适用于 ssh,所以我决定使用 https。推送工作正常,但是当我尝试克隆我的项目时,它要求我输入 每个 文件的用户名和密码。
这有点烦人。有什么解决方法吗?
2018 年编辑
这个问题一直存在,真正的解决办法在哪里?有简单直接的食谱吗?
链接 https://git-scm.com/docs/gitcredentials and git-lfs/wiki/Tutorial 可能有些东西,但没有 objective 解决方案。
我描述的情况 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
克隆过程的问题是未完成(错误),并且一直在提供用户名和密码...
尝试执行凭据时也会出现问题(请参阅 issue #2223 等)
试用报告:
git config credential.helper
什么都不输出,空消息。
git config -f .lfsconfig lfs.url https://github.com/myPrivate/MyProj1
接受任何东西...那么,浏览器是URL还是.git
URL?
在它之后命令 git add .lfsconfig
在两种情况下都说 "fatal: Not a git repository (or any of the parent directories): .git"(URL 有或没有 .git)
git config credential.https://github.com/myPrivate/MyProj1 myusername
说"fatal: not in a git directory",当然,我需要先克隆(!)..
...
您可以使用 Git 的 credential helper which git lfs supports (has a permanent store and in-memory cache 选项。
我也注意到 git lfs 有一些与此相关的 issues 已经解决。
如果实际访问文件不需要密码,并且您使用 https://server.com/path/to/repo
URL 访问,那么它应该可以工作 (as of git-lfs 0.5.3)。一种可能是您的配置有 lfs.batch = false
。尝试 git -c lfs.batch=true clone https://server.com/path/to/repo
--- 不需要凭证助手。
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.
你应该检查你的 git config credential.helper
输出。
在 Windows 上,它应该是(最近的 2017-2018 Git 版本)“经理”。
打开 Windows 凭据管理器并清除或修复任何 GitHub 凭据条目。
注意: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,但这可能已被修复。
翻译成傻瓜
(合并答案和评论)
检查git --version
,如果小于2.16,安装更好
检查你的git config credential.helper
输出,如果它是空的,
执行这一行:git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
...他们再次检查你的git config credential.helper
输出:需要是这个 /usr/...
路径。
正在克隆...
3.1。 (如评论所述)首先执行:git ls-remote https://github.com/myPrivate/MyProj1
...这应该会提示您输入 GitHub 用户名和密码帐户。重复该命令以检查第二次,它不会提示您输入任何内容。
3.2。像往常一样git clone
(小心删除旧的sudo rm -r oldBrokenBadClone
)...给username-and-password一次。
关于许多 UBUNTU LTS 服务器中的测试的最后说明...有时,当您在此过程之前进行克隆时,您无法解决问题(git pull
错误如“git-credential-libsecret : 未找到”)。解决方案是删除所有旧的克隆仓库(注意 rm -rf
)。看来你随时都可以做git config --global credential.helper
,所以,做吧。再次克隆 — 可能给 username-and-password 两次,但之后就没问题了。
我决定在 gitlab 上尝试 git lfs。我注意到它不适用于 ssh,所以我决定使用 https。推送工作正常,但是当我尝试克隆我的项目时,它要求我输入 每个 文件的用户名和密码。
这有点烦人。有什么解决方法吗?
2018 年编辑
这个问题一直存在,真正的解决办法在哪里?有简单直接的食谱吗?
链接 https://git-scm.com/docs/gitcredentials and git-lfs/wiki/Tutorial 可能有些东西,但没有 objective 解决方案。
我描述的情况 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
克隆过程的问题是未完成(错误),并且一直在提供用户名和密码...
尝试执行凭据时也会出现问题(请参阅 issue #2223 等)
试用报告:
git config credential.helper
什么都不输出,空消息。git config -f .lfsconfig lfs.url https://github.com/myPrivate/MyProj1
接受任何东西...那么,浏览器是URL还是.git
URL?
在它之后命令git add .lfsconfig
在两种情况下都说 "fatal: Not a git repository (or any of the parent directories): .git"(URL 有或没有 .git)git config credential.https://github.com/myPrivate/MyProj1 myusername
说"fatal: not in a git directory",当然,我需要先克隆(!).....
您可以使用 Git 的 credential helper which git lfs supports (has a permanent store and in-memory cache 选项。
我也注意到 git lfs 有一些与此相关的 issues 已经解决。
如果实际访问文件不需要密码,并且您使用 https://server.com/path/to/repo
URL 访问,那么它应该可以工作 (as of git-lfs 0.5.3)。一种可能是您的配置有 lfs.batch = false
。尝试 git -c lfs.batch=true clone https://server.com/path/to/repo
--- 不需要凭证助手。
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.
你应该检查你的 git config credential.helper
输出。
在 Windows 上,它应该是(最近的 2017-2018 Git 版本)“经理”。
打开 Windows 凭据管理器并清除或修复任何 GitHub 凭据条目。
注意: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,但这可能已被修复。
翻译成傻瓜
(合并答案和评论)
检查
git --version
,如果小于2.16,安装更好检查你的
git config credential.helper
输出,如果它是空的,
执行这一行:git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
...他们再次检查你的git config credential.helper
输出:需要是这个/usr/...
路径。正在克隆...
3.1。 (如评论所述)首先执行:
git ls-remote https://github.com/myPrivate/MyProj1
...这应该会提示您输入 GitHub 用户名和密码帐户。重复该命令以检查第二次,它不会提示您输入任何内容。3.2。像往常一样
git clone
(小心删除旧的sudo rm -r oldBrokenBadClone
)...给username-and-password一次。
关于许多 UBUNTU LTS 服务器中的测试的最后说明...有时,当您在此过程之前进行克隆时,您无法解决问题(git pull
错误如“git-credential-libsecret : 未找到”)。解决方案是删除所有旧的克隆仓库(注意 rm -rf
)。看来你随时都可以做git config --global credential.helper
,所以,做吧。再次克隆 — 可能给 username-and-password 两次,但之后就没问题了。