简体   繁体   English

GIT。 忽略要提交的更改

[英]GIT. Ignore changes to be commited

I have a Drupal multisite and have cloned it to setup locally. 我有一个Drupal多站点并已克隆它以在本地设置。 I have changed some setting files for db access. 我已经更改了一些db访问的设置文件。 When I do a GIT Status I get... 当我做GIT状态时,我得到......

Changes to be committed:
   (use "git reset HEAD <file>..." to unstage)

    modified:   .gitignore
    modified:   sites/default/settings.php
    modified:   sites/mysite1/settings.php
    modified:   sites/mysite2/settings.php

I don't want to commit these files I want GIT to ignore them. 我不想提交这些文件,我希望GIT忽略它们。

I have added them to .gitignore but they are still being tracked. 我已将它们添加到.gitignore,但它们仍在被跟踪。

I have tried running the following... 我试过运行以下内容......

git update-index --assume-unchanged <file>

But this does nothing. 但这没有任何作用。

How do I tell GIT to ignore these files? 如何告诉GIT忽略这些文件?

I have added them to .gitignore but they are still being tracked. 我已将它们添加到.gitignore,但它们仍在被跟踪。

You need to remove those file from the index first ( git rm --cached -- ... ), which isn't a good approach if you want to keep them versioned. 您需要首先从索引中删除这些文件( git rm --cached -- ... ),如果您想让它们保持版本化,这不是一个好方法。
And you risk to commit those changes by mistake. 而且您有可能错误地提交这些更改。
But if you don't mid that, then that will allow those files to be ignored. 但如果你不在那个中间,那么这将允许忽略这些文件。

To ignore them locally, you also can try: 要在本地忽略它们,您还可以尝试:

git update-index --skip-worktree -- <file>

I had to perform a... 我不得不表演......

git rm --cached <file>

Then commit the Deleted files 然后提交已删除的文件

Sorted 排序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM