AlexA
AlexA

Reputation: 4118

Mercurial: best way to push ignored file

Sometimes need arises to update a library or file that has previously been put into .hgignore. Normally, I would delete its entry from ignore list, commit/push a change and put ignore entry back. Is this a good practice or there is some better/elegant way to deal with such a situation in Mercurial?

Upvotes: 1

Views: 1606

Answers (2)

Paul S
Paul S

Reputation: 7755

From the hgignore man page

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.

This library is obviously tracked. At some point you did hg add <library>. hgignore is no longer part of the equation for this file. In the future just update your library and commit.

hgignore is used for things like stopping mercurial talking about certain files when you do an hg status or adding them on hg addremove. It doesn't stop mercurial noticing if a tracked file changes.

Upvotes: 4

daniel kullmann
daniel kullmann

Reputation: 14023

You don't need to remove the entry from .hgignore; you can just hg add the file.

However, when you use a GUI, this GUI might use the .hgignore entries to show you a filtered list of files you can add. In this case, you would either have to add the file maqnually with hg add, or remove the entry temporarily from the .hgignore file.

Upvotes: 1

Related Questions