Mercurial hg ignore does not work properly

☆樱花仙子☆ 提交于 2019-12-01 21:03:23

问题


Situation

$ cat .hgignore
.hgignore

$ hg status
M file1
M file2
M src/project.xml

I don't want to track the project.xml so I run

echo "project.xml" >> .hgignore

and the result is

$ cat .hgignore
.hgignore
project.xml

$ hg status
M .hgignore
M file1
M file2
M src/project.xml

So the .hgignore is now as modified even though it shouldn't be tracked and nothing happend with the project.xml. What does this mean?


回答1:


You wrote:

"M src/project.xml"

which means that src/project.xml is under version control. A file already under version control cannot be ignored! The .hgignore file is for ignoring files that are untracked (status will show a "?").

You have two solutions to ignore your file:

  1. You can either "hg forget" the file, the opposite of "hg add" (i.e., telling Mercurial not to track this file anymore), or
  2. You can use the ”-X” option as a default for status/diff/commit in your .hg/hgrc configuration file, e.g.,

    [defaults]
    status = -X <file>
    diff = -X <file>
    commit = -X <file>

which will tell hg not to include this file in the use of status, diff, and commit.



来源:https://stackoverflow.com/questions/15699917/mercurial-hg-ignore-does-not-work-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!