迁移到 Git LFS 和跟踪文件时的命令顺序
Order of commands when migrating to Git LFS and tracking files
我想将 LFS 用于现有的 Git 存储库并跟踪 *.foo
文件,同时转换历史文件。我想我可以做到:
git lfs track "*.foo"
# changed `.gitattributes` and all `.foo` files
commit -a -m "Started tracking foo files."
git lfs migrate import --everything --include="*.foo"
我应该像上面那样在导入存储库之前跟踪文件,还是应该在导入之后跟踪文件?重要吗?
两种方法都试过了,似乎导入存储库会自动打开 LFS 跟踪,因此无需单独使用 git lfs track
。
git lfs migrate import --everything --include="*.foo"
事实上,如果您首先打开跟踪,那么您将有一个额外的提交,其中文件类型被添加到 .gitattributes
。事实证明,git lfs migrate import
实际上会添加一个具有正确跟踪信息的 .gitattributes
作为历史记录中的第一个提交 。如果您没有 .gitattributes
文件,将在 过去 .
添加一个
同样,如果您没有 .gitattributes
(例如,假设您从 Subversion 存储库转换了 Git 存储库),那么如果您先添加自己的 .gitattributes
到存储库并在执行 git lfs track
之前提交它,这将导致历史记录中的 .gitattributes
版本 未 启用 LFS 跟踪。如果您决定手动添加 .gitattributes
,您应该在提交文件之前执行 git lfs track…
,以便在它出现的所有提交中打开跟踪。
所以最好的方法似乎是:
- 在执行任何其他操作之前执行
git lfs migrate…
。
- 更新 Git 添加了额外文件类型的
.gitattributes
文件(如果您还没有 .gitattributes
文件)。
总而言之,git lfs migrate import …
似乎包含 git lfs track …
功能;似乎没有必要在之前或之后单独调用后者。
我想将 LFS 用于现有的 Git 存储库并跟踪 *.foo
文件,同时转换历史文件。我想我可以做到:
git lfs track "*.foo"
# changed `.gitattributes` and all `.foo` files
commit -a -m "Started tracking foo files."
git lfs migrate import --everything --include="*.foo"
我应该像上面那样在导入存储库之前跟踪文件,还是应该在导入之后跟踪文件?重要吗?
两种方法都试过了,似乎导入存储库会自动打开 LFS 跟踪,因此无需单独使用 git lfs track
。
git lfs migrate import --everything --include="*.foo"
事实上,如果您首先打开跟踪,那么您将有一个额外的提交,其中文件类型被添加到 .gitattributes
。事实证明,git lfs migrate import
实际上会添加一个具有正确跟踪信息的 .gitattributes
作为历史记录中的第一个提交 。如果您没有 .gitattributes
文件,将在 过去 .
同样,如果您没有 .gitattributes
(例如,假设您从 Subversion 存储库转换了 Git 存储库),那么如果您先添加自己的 .gitattributes
到存储库并在执行 git lfs track
之前提交它,这将导致历史记录中的 .gitattributes
版本 未 启用 LFS 跟踪。如果您决定手动添加 .gitattributes
,您应该在提交文件之前执行 git lfs track…
,以便在它出现的所有提交中打开跟踪。
所以最好的方法似乎是:
- 在执行任何其他操作之前执行
git lfs migrate…
。 - 更新 Git 添加了额外文件类型的
.gitattributes
文件(如果您还没有.gitattributes
文件)。
总而言之,git lfs migrate import …
似乎包含 git lfs track …
功能;似乎没有必要在之前或之后单独调用后者。