我有以下 .gitignore 文件
# file named .gitignore
system/application/config/database.php
system/application/config/config.php
system/logs
modules/recaptcha/config/*
但是,当我在配置和 recapcha.php 中添加任何更改时,git 状态会警告我如下。当我向数据库添加任何更改时.php。它不显示在状态中
shin@shin-Latitude-E5420:/var/www/myapp$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# 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: modules/recaptcha/config/recaptcha.php
# modified: system/application/config/config.php
#
no changes added to commit (use "git add" and/or "git commit -a")
我该如何解决这个问题?
我在 Ubuntu 1.7.5.1 上使用 git 版本 11.04
这些文件已存储在本地提交树中。您需要先将它们从存储库中删除。这可以通过以下方式完成:
git rm --cached system/application/config/config.php modules/recaptcha/config/recaptcha.php
之后,您需要再提交一次,就可以开始了。
执行以下操作以触发 gitignore
第 1 步:在存储库中提交要修复的所有挂起更改并推送它。
第 2 步:现在你需要从 git 索引中删除所有内容,以便刷新你的 git 存储库。这是安全的。使用以下命令:
git rm -r --cached .
第 3 步:现在,您需要将所有内容添加回存储库中,这可以使用以下命令完成:
git add .
第 4 步:最后,您需要使用以下命令提交这些更改:
git commit -m "Gitignore issue fixed"
如果你的文件在你添加到 .gitignore 之前已经在 git 中,git 将继续跟踪它。如果您不想要它,请先执行"git rm"将其删除。
我猜你的 .gitignore 不在你的工作树的根中。
如果你把一个.gitignore 放在与system/application/config/config相同的目录中.php你可以使用
echo config.php >> system/application/config/.gitignore
路径相对于当前目录(或:.gitignore 是每个目录的排除/包含文件)。
见人 git-ignore