微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

致命:错误的修订版 '$GIT_COMMIT''

如何解决致命:错误的修订版 '$GIT_COMMIT''

我只想查看每次提交时 GIT_COMMIT 变量的内容

git filter-branch --tree-filter 'echo $GIT_COMMIT' -- --all

我收到此错误

WARNING: git-filter-branch has a glut of gotchas generating mangled history
         rewrites.  Hit Ctrl-C before proceeding to abort,then use an
         alternative filtering tool such as 'git filter-repo'
         (https://github.com/neWren/git-filter-repo/) instead.  See the
         filter-branch manual page for more details; to squelch this warning,set FILTER_BRANCH_SQUELCH_WARNING=1.
Proceeding with filter-branch...

fatal: bad revision '$GIT_COMMIT''

我应该如何解决这个问题?

解决方法

如果您在 Windows 上使用 CMD,那么是的,如 commentedMarc Luzzara,使用双引号有帮助。

但实际的错误消息,在 CMD shell 中带有单引号,将是:

set FILTER_BRANCH_SQUELCH_WARNING=1

git filter-branch --tree-filter 'echo $GIT_COMMIT' @

fatal: ambiguous argument '$GIT_COMMIT'': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions,like this:
'git <command> [<revision>...] -- [<file>...]'


# or,as mentioned in the OP

git filter-branch --tree-filter 'echo $GIT_COMMIT' -- --all
fatal: bad revision '$GIT_COMMIT''

相同的命令在 git bash 会话中起作用:

$ git filter-branch --tree-filter 'echo $GIT_COMMIT' -- --all
Rewrite 92a741579ad31e6ccb17fda876e084b181bbdcdb (1/4) (0 seconds passed,remaining 0 predicted)    92a741579ad31e6ccb17fda876e084b181bbdcdb
...

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。