2014-03-29 34 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'保存你的工作副本),然后提交修改。 –

相关问题