簡體   English   中英

Git在本地忽略文件

[英]Git ignore files locally

我有修改過的webroot / wp-config.php文件,但是由於obvieus的原因,我不想提交它。 我不想污染全局git config(.ignore),所以我將文件添加到

git的/信息/排除

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
webroot/wp-config.php

我跑了

git update-index --assume-unchanged webroot/wp-config.php

但是當我運行git status時,仍然看到webroot / wp-config.php已在“要提交的更改”中進行了修改。

# On branch develop
# Your branch is ahead of 'origin/develop' by 8 commits.
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   webroot/wp-config.php
#       modified:   webroot/wp-content/themes/wp-intouch/functions/twitteroauth.php
#

PS。 我也嘗試過--skip-worktree,但結果相同。

git update-index --skip-worktree webroot/wp-config.php

PS2。 Windows 7和git 1.7.11.msysgit.1

我從未真正使用過.git/info/exclude來忽略文件...(但是,由於它不是可共享的文件夾,因此我可能永遠不會在此最后使用它,而冒着其他同事提交我不想要的文件的風險在回購中查看)

因此,我堅信將此配置文件添加到全局.gitignore並沒有錯。

但是,因為您正在尋求答案而不是意見。 我建議您在wp-config.php所在的文件夾內使用.gitignore文件。 您可以在整個存儲庫中擁有多個.gitignore文件,它們可以位於子文件夾中。 例如,在local .gitignore ,Laravel中會忽略本地配置和緩存文件(例如)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM