带有方括号的git log

Red*_*edX 8 windows git git-bash

我正在尝试获取其名称中带方括号的文件的日志.万一重要:操作系统是Windows,我正在使用git bash.

如果您创建了一个文件,[]其名称一样[Start_here].bat那么git log将无法正常工作.

我试过了:

git log '[Start_here].bat'

git log \[Start_here\].bat

git log '\[Start_here\].bat'

git log -- '[Start_here].bat'

git log -- \[Start_here\].bat

git log -- '\[Start_here\].bat'
Run Code Online (Sandbox Code Playgroud)

而且他们似乎都没有工作.要么它没有显示任何提交,要么显示无关提交列表.

有人有一个有效的解决方案吗?

注意:

git mv '[Start_here].bat' 'start_here.bat'

git log --follow start_here.bat 
Run Code Online (Sandbox Code Playgroud)

确实显示了文件更改的历史记录.

编辑:

使用在新repo中执行的以下脚本,我可以看到git log正确行为,直到您添加子模块.然后它开始列出所有改变了子模块的提交......

#!/usr/bin/env bash

set -x

rm -rf test-repo
rm -rf test-submodule

mkdir test-submodule

pushd test-submodule

git init
git config --local user.name tester1
git config --local user.email test@here.com

echo "a single line" > file.txt
git add file.txt
git commit -m "first commit"

popd

mkdir test-repo
pushd test-repo

git init
git config --local user.name tester1
git config --local user.email test@here.com

git branch -m master

echo "first line" > somefile.txt
git add somefile.txt
git commit -m "First line"

echo "another line" >> somefile.txt
git add somefile.txt
git commit -a -m "Second line"

echo "A line" > "[__Odd__].txt"
git add "[__Odd__].txt"
git commit -m "Adding odd file"

echo "third line" >> somefile.txt
git commit -a -m "Another bold statement."

echo "2nd line" >> "[__Odd__].txt"
echo "more" >> somefile.txt
git add "[__Odd__].txt" somefile.txt
git commit -m "changed both in master1"

git checkout -b new_branch

echo "2nd line" >> "[__Odd__].txt"
echo "more" >> somefile.txt
git add "[__Odd__].txt" somefile.txt
git commit -m "changed both in new_branch"

git checkout master


echo "2nd line" >> "[__Odd__].txt"
echo "more" >> somefile.txt
git add "[__Odd__].txt" somefile.txt
git commit -m "changed both in master"

git submodule add -- ../test-submodule module
git commit -m "Added submodule"


git log -- "[__Odd__].txt"
Run Code Online (Sandbox Code Playgroud)

这输出:

commit c3ebc7e0daf68543d761fc3b06c7ab35e014efaf (HEAD -> master)
Author: tester1 <test@here.com>
Date:   Fri Nov 17 13:06:07 2017 +0100

    Added submodule

commit 03a935df578a2eaf3f42789bd1e89e313224797a
Author: tester1 <test@here.com>
Date:   Fri Nov 17 13:06:06 2017 +0100

    changed both in master

commit d617db69dd9468e88587e2363050fdf57ac10756
Author: tester1 <test@here.com>
Date:   Fri Nov 17 13:06:06 2017 +0100

    changed both in master1

commit 88a07e5c887d63ead4e6cedd6349dfaf85ec1866
Author: tester1 <test@here.com>
Date:   Fri Nov 17 13:06:05 2017 +0100

    Adding odd file
Run Code Online (Sandbox Code Playgroud)

注意顶部条目,它不应该在这里.它只与子模块有关,而不是我想要日志的文件.

git log -- somefile.txt 不输出与子模块相关的更改

kum*_*rsh 5

在CMD中,尝试:

git log -- "[__Odd__].txt"
Run Code Online (Sandbox Code Playgroud)

要么

git log -- ./"[__Odd__].txt"
Run Code Online (Sandbox Code Playgroud)

证明:https://imgur.com/7qqsVJ6

如果一切都失败了,你可以安装WSL,并在那里使用git处理棘手的情况.


更新1 - 来自评论:

你,先生,在Windows的git中发现了一个bug!我可以重现你的git日志,我不能使用linux的git在WSL中重现它,但可以使用WSL中的git.exe重现它!

提交了一份报告:github.com/git-for-windows/git/issues/1371,让我们来看看它是什么来的

更新2:这是代码Git软件中的一个真正的错误,由于这个问题已经修复了!这太棒了?!?!