2014-06-06 83 views
0

如何解決以下情況:Git的報告未經跟蹤的.gitignore文件,不存在

$ git status 
On branch master 
Your branch is up-to-date with 'origin/master'. 

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

     htdocs/files/.gitignore 

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

$ git rm htdocs/files/.gitignore 
fatal: pathspec 'htdocs/files/.gitignore' did not match any files 

htdocs/files.gitignore文件實際上不存在

$ cd htdocs/files/ 

$ ls -ls 
total 0 
    0 drwxr-xr-x 3 Trejder Administ  0 Jun 2 23:53 audios 
    0 drwxr-xr-x 3 Trejder Administ  0 Jun 2 23:53 files 
    0 drwxr-xr-x 3 Trejder Administ  0 Jun 2 23:53 photos 
    0 drwxr-xr-x 3 Trejder Administ  0 Jun 2 23:53 videos 

(有,然而,.gitignore文件在每個列出的文件夾下,但我懷疑,這個問題在這種情況下)

我不知道,爲什麼git有關於不存在的任何記錄htdocs/files/.gitignore?如何解決這個問題?

+4

'ls -ls'命令不會顯示.gitignore文件。使用'ls -lsa'來驗證沒有.gitignore。 – fiveclubs

+1

你不能'git rm'未跟蹤的文件。你只會「嗯」。 – hobbs

回答

4

由於.gitignore開始用了一段時,bash認爲這是一個「隱藏」的文件。這意味着您需要使用-a選件和ls才能看到它:ls -la。您可以使用less .gitignore查看文件的內容。

+0

你的答案解釋了爲什麼我不能用ls -ls看到這個文件,以及如何解決這個問題(用'ls -la'查找文件並刪除它)。但是,它並沒有解釋,爲什麼Git報告致命的:pathspec'htdocs/files/.gitignore'不匹配任何文件',如果文件真的存在?是否因爲'git rm'忽略隱藏文件? – trejder

+0

啊,我明白了...... _hobbs_'評論清除了我的思路! :''git rm'對象,因爲它只對被跟蹤的文件有效。由於'.gitignore'沒有跟蹤,所以'git rm'「不存在」。 – trejder

1

忘記Git。只需打擊它。

rm htdocs/files/.gitignore 
相關問題