bash - 将功能分支 merge 到 master 后如何建议开发人员启用 git LFS (git)

标签 bash git version-control git-bash git-lfs

详细信息:

  • 我们正在尝试将我们的仓库迁移到 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/

相关文章:

windows - 在Windows的Bash上运行Elasticsearch 1.7.1的问题

ios - 我的 xcode 在源代码管理中显示同时打开两个分支

git - 带有 Git 轮询的 Jenkins 管道无法运行

python - 您如何分发 Python 脚本?

version-control - 在命令行上执行 cvs 更新时,如何获得 cvs 冲突的摘要?

bash - Bash 脚本中的持久连接

reactjs - Yarn 可以列出所有可用的脚本吗?

bash - bash 中的 Printf 示例不会创建换行符

Git 仅还原提交中的一些文件

git - 是否可以在 Mac 上重做 GitHub Desktop 的撤消删除的提交?