本文介绍了Git filter-repo-将文件添加到根提交失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试将文件添加到分支的根目录失败,并显示以下错误:
Trying to add file to the root of the branch fails with following error:
git filter-repo --force --commit-callback "if not commit.parents: commit.file_changes.append(FileChange(b'M', 'C:\MDC\MDC.7z', $(git hash-object -w 'C:\MDC\MDC.7z'), 100644))"
Traceback (most recent call last):
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 3839, in <module>
filter = RepoFilter(args)
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 2661, in __init__
self._handle_arg_callbacks()
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 2763, in _handle_arg_callbacks
handle('commit')
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 2756, in handle
setattr(self, callback_field, make_callback(type, code_string))
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 2741, in make_callback
exec('def callback({}, _do_not_use_this_var = None):\n'.format(argname)+
File "<string>", line 2
if not commit.parents: commit.file_changes.append(FileChange(b'M', 'C:\MDC\MDC.7z', 3d5fb68077a1d627a7ec3b18f335713c4262fbf0, 100644))
^
SyntaxError: invalid syntax
Windows 10
Git版本2.24
Windows 10
Git Version 2.24
https://github.com/newren/git-filter-repo
推荐答案
从Python的角度来看 3d5fb68077a1d627a7ec3b18f335713c4262fbf0
必须是字符串('3d5fb68077a1d627a7ec3b18f335713c4262fbf0',
周围:
From Python point of view 3d5fb68077a1d627a7ec3b18f335713c4262fbf0
must be a string ('3d5fb68077a1d627a7ec3b18f335713c4262fbf0'
), so put quotes around it:
--commit-callback "if not commit.parents: commit.file_changes.append(FileChange(b'M', 'C:\MDC\MDC.7z', '$(git hash-object -w 'C:\MDC\MDC.7z')', 100644))"
这篇关于Git filter-repo-将文件添加到根提交失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!