git-p4 和配置 git-p4.largeFileExtensions

git-p4 and config git-p4.largeFileExtensions

我正在尝试将 Perforce 存储库转换为 git 存储库,使用 git-p4(对 Windows 使用 git)。我有很多图片,想为它们使用 LFS。但是,我似乎无法让 git-p4.largeFileExtensions 配置设置与多个扩展一起正常工作。如果我执行以下命令:

git config       git-p4.largeFileSystem     GitLFS
git config       git-p4.largeFileExtensions png
git config --add git-p4.largeFileExtensions jpg
git p4 clone --verbose //depot/project@all .

我得到(如果我使用两个以上,所有对都报告类似的警告):

WARNING: These git config values clash:
  git config "git-p4.largefileextensions" = "png"
  git config "git-p4.largefileextensions" = "jpg"

.git/config 文件是我所期望的,是 largeFileExtensions 的多值条目:

[git-p4]
        largeFileSystem = GitLFS
        largeFileExtensions = png
        largeFileExtensions = jpg

然而 .gitattributes 创建的文件看起来像:

#
# Git LFS (see https://git-lfs.github.com/)
#
*.png
jpg filter=lfs -text

是我做错了什么,还是 largeFileExtensions 属性的格式不同?

这似乎是 git for Windows 为 Windows 输出不正确的行结尾的问题。如果我 运行:

git config --get-all git-p4.largeFileExtensions

它会给我:

png\r
jpg\r

git-p4.py 脚本中,它使用split(os.linesep) 拆分命令行的输出。在 Windows、os.linesep = '\r\n' 上,因此不会拆分行。如果我将脚本更改为使用 splitlines(),那么它仍然会发出冲突警告,但是,似乎跟踪现在是正确的。

请注意,除了 git-p4.largeFileExtensions,“git p4”还用于忽略 lfs.storage 配置变量,已使用 Git 2.25(2020 年第一季度)更正).

参见 commit ea94b16 (11 Dec 2019) by r.burenkov (panzercheg)
(由 Junio C Hamano -- gitster -- in commit 20aa6d8 合并,2019 年 12 月 25 日)

git-p4: honor lfs.storage configuration variable

Signed-off-by: r.burenkov

"git lfs" allows users to specify the custom storage location with the configuration variable lfs.storage, but when interacting with GitLFS pointers, "git p4" always uses the hardcoded default that is the .git/lfs/ directory, without paying attention to the configuration.

Use the value configured in lfs.storage, if exists, as all the "git" operations do, for consistency.

我使用 git p4 将现有的 Perforce 库和工作区迁移到新的 git 存储库,我使用 git lfs migrate 将大文件移动到其他地方。查看很棒的 github 教程 here

要列出文件及其大小:

git lfs migrate info --everything

删除历史记录中的所有 .bin 文件(重写提交)并设置 LFS 配置:

git lfs migrate import --include="*.bin"

在 git 将新的 repo 推送到远程之前,您还可以将 GitHub LFS 服务器 url 更改为另一个 implementation。通过执行 git lfs env 检查 LFS 配置,并将 url 更改为 git config -f .lfsconfig lfs.url https://your.server.com/info/lfs