How to add .hgignore to my Mercurial folder?

故事扮演 提交于 2019-12-21 03:40:23

问题


I'm learning to use Mercurial, and its learning curve is pretty straightforward. But one of my problem is, I can't add the .hgignore file to Mercurial folder. Windows (7) does not allow me to do this, and when I run the command

hg add .hgignore

, it returns error:

the system cannot find the specified file.

How can I create/add this file?


回答1:


Execute

touch .hgignore

or

echo "" > .hgignore

in the needed directory




回答2:


Create it from the command line

echo syntax: glob > .hgignore



回答3:


You don't need to add it to Mercurial directory. You should place .hgignore to repository's root directory.

The Mercurial system uses a file called .hgignore in the root directory of a repository to control its behavior when it searches for files that it is not currently tracking

You also can set up global .hgignore files:

In addition, a Mercurial configuration file can reference a set of per-user or global ignore files. See the hgrc(5) man page for details of how to configure these files. Look for the "ignore" entry in the "ui" section.

And there you can see instructions to define ignore file in mercurial.ini (or hgrc) file:

ignore A file to read per-user ignore patterns from. This file should be in the same format as a repository-wide .hgignore file. This option supports hook syntax, so if you want to specify multiple ignore files, you can do so by setting something like ignore.other = ~/.hgignore2. For details of the ignore file format, see the hgignore(5) man page.



来源:https://stackoverflow.com/questions/4965108/how-to-add-hgignore-to-my-mercurial-folder

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