2014-03-29 35 views
5

問題1: 我試圖讓git跟蹤我的文件「altro.src」但沒有成功。該文件被git完全忽略,即使沒有在.gitignore中列出,它也不會顯示--ignign,即使我嘗試添加它,它也不會被考慮。git沒有看到文件...如何理解有什麼不對?

我是一個git的新手(第三次提交...我已經卡住了),但我有一些與hg的長期經驗。

下面是一些命令來顯示問題:

$ ls -al altro.src 
-rw-r--r-- 1 myuser staff 560 28 Mar 09:02 altro.src 

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

Changes not staged for commit: 
    (use "git add <file>..." to update what will be committed) 
    (use "git checkout -- <file>..." to discard changes in working directory) 

    typechange: moebius.html 

no changes added to commit (use "git add" and/or "git commit -a") 

$ cat .gitignore 
*~ 
.DS_Store 

/index.html 
/index.en.html 
/moebius.html 
/moebius.en.html 
/altro.html 
/altro.en.html 
$ git status . --ignored 
On branch master 
Your branch is up-to-date with 'origin/master'. 

Changes not staged for commit: 
    (use "git add <file>..." to update what will be committed) 
    (use "git checkout -- <file>..." to discard changes in working directory) 

    typechange: moebius.html 

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

    .DS_Store 
    .gitignore~ 
    altro.en.html 
    altro.html 
    altro.src~ 
    base.src~ 
    build_site.py~ 
    index.en.html 
    index.html 
    moebius.en.html 
    moebius.src~ 

no changes added to commit (use "git add" and/or "git commit -a") 
$ git add altro.src 
$ git status . 
On branch master 
Your branch is up-to-date with 'origin/master'. 

Changes not staged for commit: 
    (use "git add <file>..." to update what will be committed) 
    (use "git checkout -- <file>..." to discard changes in working directory) 

    typechange: moebius.html 

no changes added to commit (use "git add" and/or "git commit -a") 

問題2:我不明白擺脫該消息的什麼文件上moebius.html手段「typechange」,以及如何(moebius.html是在我的.gitignore,我希望它被忽略)。

回答

3

我懷疑altro.src沒有改變,因爲您之前檢查過它。如果嘗試放置未更改的文件,Git不會警告您,但它不會將其添加到臨時區域(索引),因此它不會顯示在git status中。換句話說,如果你要求Git添加已經存在的東西,那麼它就沒有工作要做。

您可以通過運行git diff altro.src(可能不會顯示更改)和git log altro.src(查看您的哪些提交在之前添加它)來檢查此問題。

typechange請注意,文件類型已更改(例如從常規文件更改爲文件鏈接)。

+0

我覺得很愚蠢......是的,這是發生了什麼事。 –

+0

關於* typechange *問題:是的文件是一個符號鏈接,現在它是一個普通的文件。此外,該文件先前被跟蹤,但現在我想讓git忽略它(因爲它是由源文件生成的)。我怎樣才能擺脫這個信息? –

+0

如果你不想再跟蹤對'moebius.html'的修改,你可以使用'git rm --cached moebius.html'('--cached'保存你的工作副本),然後提交修改。 –

相關問題