详细信息:
- 我们正在尝试将我们的仓库迁移到 git LFS
- 我有一个将启用 git lfs 的分支,我正在做的是更新一个 .gitattributes 文件,并创建一个跟踪器,该跟踪器又创建指针来跟踪需要成为 LFS 一部分的所有文件
- 现在我必须建议开发人员在将此功能分支 merge 到 default/master 后他们需要做什么
我需要了解的问题?
- 现在我所建议和发现的一般是在更新到主/默认之前,即重新设置到主/默认,我告诉他们对他们拥有的所有功能分支执行以下操作,显然到目前为止没有 git lfs 的变化
brew install git-lfs (this will be system-wide)
git lfs install (this will be on the root directory of the repo, for each branch)
- 现在对于开发人员来说,这将是一个手动步骤,他们不知何故希望这对他们来说是自动化的,我认为这可能是通过 git hooks 或其他方式完成的,这样他们就不必更新每个分支 我在想这样的管道 bash 命令可以做到吗?这可行吗
for branch in $(git for-each-ref --format='%(refname)' refs/heads/); do
git lfs install "$branch";
done
更新1
- 似乎上面的代码确实在您本地历史记录中的所有分支上执行了
git lfs install
,并且一次性完成。 - 但我仍然想知道和理解什么是
最佳
实践
最佳答案
应该不需要在所有分支中运行 git lfs install
——一旦你在 repo 中执行 install
,它就会为该 repo 永久设置。来自帮助:
$ git lfs install --help
git lfs install [options]
Perform the following actions to ensure that Git LFS is setup properly:
* Set up the clean and smudge filters under the name "lfs" in the global Git
config.
* Install a pre-push hook to run git lfs pre-push for the current repository,
if run from inside one. If "core.hooksPath" is configured in any Git
configuration (and supported, i.e., the installed Git version is at least
2.9.0), then the pre-push hook will be installed to that directory instead.
Hook 存储在 .git
文件夹中,因此当您 checkout 不同的分支时它们不会受到影响。
现在,您似乎已经意识到,如果人们的分支比您 merge 的新 .gitattributes
文件还旧,他们将需要重新设置这些分支的基线以获取更改并确保正确的文件被视为 LFS 文件。但这与 git lfs install
无关。
关于bash - 将功能分支 merge 到 master 后如何建议开发人员启用 git LFS (git),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64178437/