【问题标题】:git-lfs checkout remote branchgit-lfs 签出远程分支
【发布时间】:2016-11-10 00:52:44
【问题描述】:

我正在尝试从使用 lfs 存储文件的远程检查分支:

git remote add remoteRepo git@github.com:user/remoteRepo-lfs.git
git fetch remoteRepo
git checkout -b test remoteRepo/master

值得一提的是,remote 已经受制于 bozaro/git-lfs-migrate 工具。结帐过程停止并出现错误和

git lfs logs last

显示:

git-lfs/1.4.4 (GitHub; linux amd64; go 1.7.3; git cbf91a9)
git version 2.10.2

$ git-lfs smudge -- testText.log
Error downloading object: testText.log (dc56c0fc4d655b0895d83cd61b121f30cb74bda428655db4144e4a1c8b582b57)

Smudge error: Error buffering media file: Object not found on the server.: 
github.com/github/git-lfs/errors.newWrappedError
    /Users/ttaylorr/dev/go/src/github.com/github/git-lfs/errors/types.go:166
github.com/github/git-lfs/errors.NewSmudgeError
    /Users/ttaylorr/dev/go/src/github.com/github/git-lfs/errors/types.go:252
github.com/github/git-lfs/lfs.PointerSmudge
    /Users/ttaylorr/dev/go/src/github.com/github/git-lfs/lfs/pointer_smudge.go:69
github.com/github/git-lfs/lfs.(*Pointer).Smudge
    /Users/ttaylorr/dev/go/src/github.com/github/git-lfs/lfs/pointer.go:64
github.com/github/git-lfs/commands.smudgeCommand
    /Users/ttaylorr/dev/go/src/github.com/github/git-lfs/commands/command_smudge.go:66
github.com/github/git-lfs/vendor/github.com/spf13/cobra.(*Command).execute
    /Users/ttaylorr/dev/go/src/github.com/github/git-lfs/vendor/github.com/spf13/cobra/command.go:477
github.com/github/git-lfs/vendor/github.com/spf13/cobra.(*Command).Execute
    /Users/ttaylorr/dev/go/src/github.com/github/git-lfs/vendor/github.com/spf13/cobra/command.go:551
github.com/github/git-lfs/commands.Run
    /Users/ttaylorr/dev/go/src/github.com/github/git-lfs/commands/run.go:65
main.main
    /Users/ttaylorr/dev/go/src/github.com/github/git-lfs/git-lfs.go:33
runtime.main
    /usr/local/Cellar/go/1.7.3/libexec/src/runtime/proc.go:183
runtime.goexit
    /usr/local/Cellar/go/1.7.3/libexec/src/runtime/asm_amd64.s:2086

ENV:
LocalWorkingDir=/home/person/Projects/proteus/proteus
LocalGitDir=/home/person/Projects/proteus/proteus/.git
LocalGitStorageDir=/home/person/Projects/proteus/proteus/.git
LocalMediaDir=/home/person/Projects/proteus/proteus/.git/lfs/objects
LocalReferenceDir=
TempDir=/home/person/Projects/proteus/proteus/.git/lfs/tmp
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false
BatchTransfer=true
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic
UploadTransfers=basic
GIT_DIR=.git
GIT_PREFIX=

一个 git-lfs 环境显示:

git-lfs/1.4.4 (GitHub; linux amd64; go 1.7.3; git cbf91a9)
git version 2.10.2

Endpoint=https://github.com/username/repo.git/info/lfs (auth=none)
  SSH=git@github.com:username/repo.git
Endpoint (remoterepo)=https://github.com/username/remoteRepo.git/info/lfs (auth=none)
  SSH=git@github.com:username/remoteRepo.git
LocalWorkingDir=/home/person/Projects/proteus/proteus
LocalGitDir=/home/person/Projects/proteus/proteus/.git
LocalGitStorageDir=/home/person/Projects/proteus/proteus/.git
LocalMediaDir=/home/person/Projects/proteus/proteus/.git/lfs/objects
LocalReferenceDir=
TempDir=/home/person/Projects/proteus/proteus/.git/lfs/tmp
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false
BatchTransfer=true
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic
UploadTransfers=basic
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"

我已经成功克隆了 remoteRepo-lfs

git clone git@github.com:user/remoteRepo-lfs.git

并且还能够通过在 .lfsconfig 文件中指定来成功签出分支:

[lfs]
  url = https://github.com/username/remoteRepo-lfs.git
[remote "remoteRepo"]
  lfsurl = https://github.com/username/remoteRepo-lfs.git/info/lfs

这似乎覆盖了原点的端点 url。有没有办法设置本地目录,以便我可以根据它们各自的端点 url 从源和远程推送/拉取/签出 lfs 文件?

【问题讨论】:

  • “git checkout -b test remoteRepo/master”命令中的“test”是什么?
  • 这将是跟踪 remoteRepo/master 分支的本地分支的名称。
  • 拉了会不会出现?
  • @Eddie-MSFT 我不确定您所说的“拉动它”是什么意思。我的理解是,在添加遥控器后,我必须获取遥控器,然后我可以签出一个跟踪远程分支的分支。签出分支后,我可以定期执行“git pull”,这实际上是“git fetch”和“git merge”来更新分支的本地副本。

标签: git github version-control git-lfs


【解决方案1】:

我通过修改 lfs 过滤器(在 ~/.gitconfig 中)找到了解决此问题的方法。即:

[filter "lfs"]
  smudge = git-lfs smudge --skip %f
  required = true
  clean = git-lfs clean -- %f

git-lfs smudge 将文件指针转换为实际文件。使用此解决方法,我必须执行

git lfs fetch

后跟一个

git lfs checkout

检索/访问文件的内容。我不清楚为什么需要这种解决方法。查看 git-lfs 上的问题,这似乎是一项正在进行的一般工作。

(例如https://github.com/github/git-lfs/issues/834)。

【讨论】:

    【解决方案2】:

    你安装过 git-lfs 吗?如果没有,您可以安装here。看来你还没有GIT_LFS_PATH,可以参考我自己的环境。

    DownloadTransfers=basic
    UploadTransfers=basic
    GIT_LFS_PATH=C:\Program Files\Git LFS
    git config filter.lfs.smudge = "git-lfs smudge -- %f"
    git config filter.lfs.clean = "git-lfs clean -- %f"
    

    您是否在 GitHub 上创建了 git-lfs 存储库?您可以尝试使用https://github.com/username/remoteRepo-lfs.git 来检查它是否真的存在。

    而且我也很困惑,您的本地目录如下:

    LocalWorkingDir=/home/person/Projects/proteus/proteus
    LocalGitDir=/home/person/Projects/proteus/proteus/.git
    LocalGitStorageDir=/home/person/Projects/proteus/proteus/.git
    LocalMediaDir=/home/person/Projects/proteus/proteus/.git/lfs/objects
    LocalReferenceDir=
    TempDir=/home/person/Projects/proteus/proteus/.git/lfs/tmp
    

    我的本​​地目录是这样的:

    LocalWorkingDir=C:\Users\TFSTest\New folder\Git2
    LocalGitDir=C:\Users\TFSTest\New folder\Git2\.git
    LocalGitStorageDir=C:\Users\TFSTest\New folder\Git2\.git
    LocalMediaDir=C:\Users\TFSTest\New folder\Git2\.git\lfs\objects
    LocalReferenceDir=
    TempDir=C:\Users\TFSTest\New folder\Git2\.git\lfs\tmp
    

    【讨论】:

    • git-lfs 肯定已安装,否则命令“git-lfs env”将不起作用。我的印象是默认的 lfs 服务器就是存储库本身,它确实存在。至于我的本地目录,我在 Ubuntu 14.04 LTS 上。您的目录似乎是 Windows 系统的指示符?
    • 我在查找有关环境变量的完整文档时遇到了麻烦,但 GIT_LFS_PATH 的默认值似乎是 C:\Program Files\Git LFS,如果你想要一个不同的值,你只需要明确设置它。
    猜你喜欢
    • 2010-12-19
    • 1970-01-01
    • 2023-01-20
    • 2015-09-26
    • 1970-01-01
    • 2018-12-22
    • 2021-12-31
    相关资源
    最近更新 更多