git - 如何更改 git-crypt key

标签 git git-crypt

我使用 git-crypt fork 了一个 repo我需要更新 git-crypt key ,以便上游 git-crypt key 无法解密新的存储库。
git-crypt help文档和 README似乎没有解释如何更改 git-crypt key 。

我尝试了各种删除 git-crypt 配置并重新初始化的方法。不幸的是,所有这样做的尝试似乎都破坏了各种事情,例如 git diff 显示诸如 smudge filter git-crypt failed 之类的错误。 .其中一些行为记录在 Running git-crypt init on an already initialized repository renders the data unreadable .在 https://github.com/AGWA/git-crypt/issues/47 的评论中没有任何建议防止 git diff fatal error 。 (我对 git diff 显示未加密的二进制文件历史记录的无用输出感到满意,但对于 git diff 在某些提交中给出 fatal error 是不行的,即使是未加密的文件也无法进行比较。)

这似乎是 git-crypt 的主要要求,所以我不敢相信这不受支持,例如如果因为有人离开公司而需要轮换 git-crypt key 。

最佳答案

通过一些工作,您可以旋转中央 key (不是 gpg,我不知道)

  • 删除 .gitattributes 文件。这将解密您的 secret 。
  • stash 更改(在本地存储未加密的 secret )
  • 删除 .gitattributes 和所有 secret 文件。犯罪。 (操作 2+3 是为了您不必提交任何明文 secret )
  • 做'git-crypt lock',在这种情况下它只会扔掉你的 key
  • 执行 'git-crypt init' 来创建一个新 key 。
  • 取消 stash 文件并重新创建 .gitattributes
  • 提交

  • 请注意,协作者需要在 pull 新更改之前执行“git-crypt lock”,以便丢弃旧 key 并仅在纯 git 模式下处理文本文件(尽管 secret 仍然加密)。

    更新后,只需使用新 key git-crypt 解锁。

    关于git - 如何更改 git-crypt key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47524175/

    相关文章:

    git - 在多用户环境中使用 git 决定应该实现什么、不应该实现什么

    git 删除旧分支与 --no-ff merge

    git - 如何从github API获取仓库中某行代码的blame信息

    windows - 如何在 Windows 上安装 Git-crypt?

    git - 如何在 gitlab ci/cd 管道上的 docker build 期间解锁 git-crypt 文件

    git - `git branch -r` 未显示远程 git 分支?

    git - 如何在 *Windows* 中将 Mercurial 存储库转换为 Git...?

    git - 如何加密文件并将其存储在 LFS 上?

    GitKraken 与 git-crypt 的互操作性