I hate seeing nearly every directory in my repository list each file twice, once with a dot in front of it and once without. I tried adding .*
to my .hgignore file, but it has no effect. Is this the wrong syntax, and more importantly, is it a bad idea to try this in the first place? Thanks.
相关问题
- php--glob for searching directories and .jpg only
- Mercurial compared to private branches in SVN
- How to abandon all Mercurial changes that haven
- Windows permissions on a directory: Mercurial - hg
- hg shelve installed but hg: unknown command 'u
相关文章
- Mercurial Commit Charts / Graphs [closed]
- What is the tortoisehg gui equivalent of doing “hg
- How to use Mercurial from Visual Studio 2010?
- Is there a version control system abstraction for
- Can NOT List directory including space using Perl
- Mercurial discard local changes of a file or group
- Mercurial .hgignore Negative Lookahead
- Brace expansion in python glob
You've got almost the right answer in the comments from gavinb, but the match was a little to broad. However, key concept about ignoring after the face was provided by RogerPage, again in a comment (what's with everyone preferring comments to answers?).
Let's look at these nine files:
If in the default regex mode for hgignore you do:
You ignore eight of those nine files:
which is more broad than you said you wanted. It's ignoring anything with a dot anywhere in it.
To ignore all files and directores (not what you said, but what you seem to want) beginning with a dot you use this regexp pattern:
which says that the thing before the literal dot has to be the start of the line (
^
) or a slash.That caught only files or directories that start with a dot.
However, the other key concept that came up, was that .hgignore has no effect after a file has been added. It will prevent adding by wild card, but you can always override .hgignore with an explicit
hg add
. and once files have been added the hgignore is no longer consulted.That's actually really handy because you can ignore broadly (ex:
.*\.jar
) and then add the exceptions you do want manually w/o having to futz with your hgignore file. However, in this case it means you need tohg rm
the files you've already added accidentally, and tonfa showed how to do that (so long as there are no spaces in your filenames).In the end it sounds like what you want in your .hgignore file is:
and that you need to remove the ones you've already added:
I use this in my
.hgignore
:Which reads: periods not preceded by something other than a forward slash.
Ry4an's solution is also good, I've used that one before too. Not sure which is more efficient.
https://regex101.com/r/dB4bW7/1