我有一个音乐文件的 git 存储库,最近我发现有些文件被删除了。
我想我不小心删除了它们,但现在我只是短暂地陶醉于我有先见之明的事实
使用 git 存储库,因此我当前的 git 状态验证它们已被删除。以下是一些清单:
# deleted: Steve_Erquiaga-Cafe_Paradiso/03 - Arioso__J.S._Bach_.flac
# deleted: "Steve_Erquiaga-Cafe_Paradiso/04 - S\303\203\302\251r\303\203\302\251nade__Rachmaninov__from_Moreaux_de_fantasie.flac"
# deleted: "Steve_Erquiaga-Cafe_Paradiso/05 - After_a_Dream__Faure___Apr\303\203\302\250s_Une_R\303\203\302\252ve_.flac"
# deleted: Steve_Erquiaga-Cafe_Paradiso/06 - Prelude_in_C_Minor__J.S._Bach__from_The_Well-Tempered_Clavier.flac
# deleted: Steve_Erquiaga-Cafe_Paradiso/07 - If_Dreams_Could_Dance__Erquiaga_.flac
我已经使用以下方法恢复了一首名称中不包含特殊字符的歌曲:
$git checkout "copy/pasted-in_name_from the output above"
然而,某些名称中的特殊字符阻碍了我恢复它们的简单方法:
$git checkout 'Steve_Erquiaga-Cafe_Paradiso/05 - After_a_Dream__Faure___Apr\303\203\302\250s_Une_R\303\203\302\252ve_.flac'
Error:
路径规范 'Steve_Erquiaga-Cafe_Paradiso/05 - After_a_Dream_Faure__Apr\303\203\302\250s_Une_R\303\203\302\252ve_.flac' 与 git 已知的任何文件不匹配。
我认为这本身不是 git 问题,而是 shell 特殊字符转义或翻译问题。
我尝试将显示的名称放在双引号中,但我收到了相同的消息。我还尝试使用外部双引号,并在每个“内部双引号”前面加上反斜杠,获得相同类型的错误消息。
如何构建一个可以使用这些文件名的 git checkout 命令?
您可以尝试使用printf
,它理解 3 个字符的八进制转义符,例如:
git checkout -- "$(printf "Steve_Erquiaga-Cafe_Paradiso/05 - After_a_Dream__Faure___Apr\303\203\302\250s_Une_R\303\203\302\252ve_.flac")"
恐怕我还没有测试过这个,但我认为它应该有效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)