2016-06-07 122 views
1

刪除不存在的文件有資料表明git的狀態顯示:從混帳

git status 
On branch master 
Your branch is ahead of 'origin/master' by 2 commits. 
(use "git push" to publish your local commits) 

Untracked files: 
(use "git add <file>..." to include in what will be committed) 

"src/HomeBundle/Entity/\320Apartments.php" 
"src/HomeBundle/Repository/\320ApartmentsRepository.php" 
"src/HomeBundle/Resources/config/doctrine/\320Apartments.orm.yml" 

nothing added to commit but untracked files present (use "git add" to track) 

我想從我的計算機中刪除這些文件,因爲我創造了他們意外

我嘗試執行:

git rm "src/HomeBundle/Entity/\320Apartments.php" 
fatal: pathspec 'src/HomeBundle/Entity/\320Apartments.php' did not match any files 

git rm '"src/HomeBundle/Entity/\320Apartments.php"' 
fatal: pathspec '"src/HomeBundle/Entity/\320Apartments.php"' did not match any files 

rm '"src/HomeBundle/Entity/\320Apartments.php"' 
rm: cannot remove ‘"src/HomeBundle/Entity/\\320Apartments.php"’: No such file or directory 

rm "src/HomeBundle/Entity/\320Apartments.php" 
rm: cannot remove ‘src/HomeBundle/Entity/\\320Apartments.php’: No such file or directory 

git rm '"src//HomeBundle//Entity//\320Apartments.php"' 
fatal: pathspec '"src//HomeBundle//Entity//\320Apartments.php"' did not match any files 

git rm "src//HomeBundle//Entity//\320Apartments.php" 
fatal: pathspec 'src//HomeBundle//Entity//\320Apartments.php' did not match any files 

rm '"src//HomeBundle//Entity//\320Apartments.php"' 
rm: cannot remove ‘"src//HomeBundle//Entity//\\320Apartments.php"’: No such file or directory 

請幫我找到並移除它們!

回答

1

你鴕鳥政策需要一個像雙斜線在「SRC // ......」

你使用Linux終端,所以你可能會使用bash。嘗試自動完成:

rm src/H<tab><tab>

  • 你寫rm src/H然後按Tab鍵兩次,將完成對 「SRC/HomeBundle」,然後添加 「/ E」,並按下Tab鍵兩次。這將有助於您在必要時自動完成轉義字符的路徑。
+0

非常感謝!雙引號是由git shell簡單顯示的。我的錯誤文件位於/ src/HomeBundle/Entity /中。我通過MC刪除它們。 –

+0

@DmitriyUrazov,很好'MC'的幫助。注意,雙引號('「')在路徑中是可以的,但雙斜槓(」//「)不是。 – JrBenito

0

使用git rm file_name命令刪除文件跟蹤。

+0

值得一提的是,文件沒有被跟蹤,所以這不是Git相關的。雖然,git rm會做這項工作,因爲git非常好;) – JrBenito

+0

我也試過這種方法, git rm'「src // HomeBundle // Entity // \ 320Apartments.php'' fatal:pathspec'」 src // HomeBundle // Entity // \ 320Apartments.php「'與任何文件不匹配 git rm」src // HomeBundle //實體// \ 320Apartments.php「 fatal:pathspec'src // HomeBundle // Entity //\320Apartments.php'不匹配任何文件 –

+1

檢查你的文件路徑,他們聞到!嘗試用適當的斜線指定絕對路徑,我的意思是在Windows上向後並在Linux上向前。 –

1

您可以運行'git clean -f'從工作目錄中刪除所有未跟蹤的文件。添加「-d」選項以刪除目錄。您也可以使用'git clean -n'來檢查將要刪除的內容(所謂的「空運行」)。