开发者

Git: Removing a folder with \r in the path

开发者 https://www.devze.com 2023-01-11 06:23 出处:网络
So somehow OS X allowed me to create a folder with the name \"assets\\rassets\\rassets\". Yep, those are \\r linebreaks.

So somehow OS X allowed me to create a folder with the name "assets\rassets\rassets". Yep, those are \r linebreaks.

Now I've renamed it, but git can't find it to remove it.

git rm "assets\rassets\rassets/default_app_icon.psd"
fatal: pathspec 'assets\rassets\rassets/default_app_icon.psd' did not match any files
开发者_JAVA技巧

All combinations of escaping with \ and " don't do anything.


That's because '\r' doesn't really mean anything to git or your shell. You need to give it an actual carriage return character.

You can use bash's filename completion to accomplish this -- just type 'git rm assets', and start hitting tab until you get where you need to be.

You can also use the shell command printf with backticks. This should work (just did for me on OS X):

git rm `printf 'assets\rassets\rassets/default_app_icon.psd'`

The printf command works like C's printf(), with support for all the same escape characters (including '\r').

0

精彩评论

暂无评论...
验证码 换一张
取 消