.gitignore没有使用新的回购

时间:2015-04-09 15:42:04

标签: git gitignore

我有一个全新的git repo,我刚刚检查过。然后,我使用以下行更新了.gitignore

wp-config.php

我的git status现在写着:

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

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)

我添加并提交此文件(本地)。然后我更新了wp-config.php文件。

但是,现在,当我运行git status时,我得到以下内容:

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

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:   wp-config.php

我已经完成了这个.gitignore is not working 但由于我使用了一个完全新鲜的回购,所以这些要点似乎并不适用。

还有其他建议吗?

当然,我不必将其提交到遥控器(&#39; origin / master&#39;)以在本地忽略它?

2 个答案:

答案 0 :(得分:4)

看起来git已经在跟踪该文件,因此.gitignore无效。

您可以停止git跟踪它:

git rm --cached wp-config.php

之后,您不应在wp-config.php输出中看到git status

答案 1 :(得分:1)

如果git已经跟踪了该文件,则需要在将其添加到.gitignore后将其删除。这样可以防止它被进一步跟踪:

git rm --cached wp-config.php