【问题标题】:git is not ignoring an eclipse .version filegit 没有忽略 eclipse .version 文件
【发布时间】:2015-01-06 19:39:09
【问题描述】:

这可能很简单,但我不能让 git 忽略它。我已将不同的组合放入存储库根目录中的 .gitignore 文件中。

但我还是看到了:

 $ 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)

    modified:   .gitignore
    modified:   MyProject/build/.version

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

我的 .gitignore 文件中有“构建”。我尝试过“MyProject/build/.version”、“build/.version”、“.version”及其各种组合。但也许不是正确的组合。

【问题讨论】:

标签: eclipse git gitignore


【解决方案1】:

如果您只是将build 添加到您的.gitignore,那么之前跟踪的文件仍将被跟踪。 .gitignore 仅阻止 git 跟踪与给定模式匹配的 新的、未跟踪的 文件。要从 git 的历史记录中删除文件,而不在本地删除文件,您可以运行

git rm -r --cached build

删除构建目录中的所有内容,或

git rm --cached MyProject/build/.version

(或任何路径)仅删除一个文件。

【讨论】:

    【解决方案2】:

    尝试在您的 .gitignore 中输入以下内容:

    /build
    

    另一件要尝试的是

    build/
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多