本文介绍了git filter分支到git filter repo转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照以下命令对git存储库中的所有提交执行更漂亮的操作:

I am following this command to perform prettier over all commits in my git repository:

git filter-branch --tree-filter 'prettier --write "**/**.js" || echo "Error formatting, possibly invalid JS"' -- --all

我想在 git filter repo 中执行相同的操作,但我什至没有确定这是否可以实现.谁能帮忙使用git filter repo来解决这个问题?

I want to perform the same in git filter repo but I am not even sure whether that is achievable. Can anyone help on how to approach this with git filter repo?

推荐答案

是的,它是 blob回调,并允许您在所需的blob上调用所需的任何脚本/命令,类似于在 newren/git-filter-repo问题45 此示例

Yes, it is a blob callback and allows you to call any script/command you want on said blob, similar to what is done in newren/git-filter-repo issue 45, and this example

git filter-repo --force --blob-callback '
  import black
  blob.data = black.reformat_commit(blob.data.decode(), mode=black.FileMode()).encode()
'

使用 reformat_commit就像在此python脚本中一样.

With reformat_commit as in this python script.

这篇关于git filter分支到git filter repo转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 11:44