git filter分支到git filter repo转换 [英] git filter branch to git filter repo conversion

查看:141
本文介绍了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?

推荐答案

我想在git filter repo中执行相同的操作,但是我什至不确定是否可以实现

I want to perform the same in git filter repo but I am not even sure whether that is achievable

是的,它是

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转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆