[英]git .ignore not working in a directory
我有以下 .gitignore 文件
# file named .gitignore
system/application/config/database.php
system/application/config/config.php
system/logs
modules/recaptcha/config/*
但是,當我在 config 和 recapcha.php 中添加任何更改時,git status 會警告我如下。 當我向database.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 11.04 上使用 git 版本 1.7.5.1
這些文件已經存儲在您的本地提交樹中。 您需要先從存儲庫中刪除它們。 這可以通過:
git rm --cached system/application/config/config.php modules/recaptcha/config/recaptcha.php
之后,您需要再進行一次提交,然后就可以開始了。
執行以下操作以觸發gitignore
第 1 步:在要修復的存儲庫中提交所有待處理的更改並推送它。
第 2 步:現在您需要從 git 索引中刪除所有內容以刷新您的 git 存儲庫。 這是安全的。 使用這個命令:
git rm -r --cached .
第 3 步:現在您需要將所有內容添加回 repo,這可以使用以下命令完成:
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 是每個目錄的排除/包含文件)。
參見 man git-ignore
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.