tadalafil 5 mg viagra naturale indiano köpa viagra på apoteket propecia prezzo levitra pil propecia andorre kamagra andorra køb cialis online prix cialis 20 levitra belgique acquista cialis generico viagra pris apotek cialis rezeptfrei schweiz viagra bestellen forum acheter cialis en pharmacie
livraison viagra rapide farmacias viagra sin receta kamagra in berlin kaufen viagra online rezept cialis køb acquisto kamagra online viagra aus indien gefährlich cialis de 10 mg viagra farmacia ahumada kosten viagra pharmacie en ligne belgique viagra natural venta cialis preisliste viagra in der apotheke kaufen cialis generico india

How to make Git ignore files that already exist in your project

For a project I’m working on, I had to change some files with personal settings, and the files kept showing up with a

git status

.

Adding files to .gitignore that are already tracked does not work. (and it’s actually pretty well documented in the documentation). In stead, it’s possible to use this command:

git update-index --assume-unchanged [filename(s)]

From git-update-index manual page:

--assume-unchanged --no-assume-unchanged

When these flags are specified, the object names recorded for the paths are not updated. Instead, these options set and unset the “assume unchanged” bit for the paths.

When the “assume unchanged” bit is on, git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell git when you change the working tree file. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

Fantastic! my system files are now ignored by git :)

It’s an incredibly useful tip for example if you have files that MUST live in the repository and that servers/editors change. In this particular project, Tomcat keeps changing two files. Furthermore I have changed the log-level from INFO to WARN which I should not commit into the repository.

git update-index –assume-unchanged

lets me do exactly that.

5 Responses to “How to make Git ignore files that already exist in your project”

  1. Ignore Git files that already exist in the repository « Blog Says:

    [...] I made changes to some config files for dev purposes. And I didn’t want to commit that back into git. The problem is that .gitignore and .git/info/exclude don’t work on a file already in the repository. So after googling a bit, I found a way to do this here: http://justaddwater.dk/2009/12/07/how-to-make-git-ignore-files-that-already-exist-in-your-project/ [...]

  2. roger Says:

    for followers:

    $ git update-index –assume-unchanged source_code/PushSource.vxcproj
    fatal: Unable to mark file source_code/PushSource.vxcproj

    meant “that file doesn’t exist”

  3. EduBoris Says:

    Perfect!

    Worked well for existing files, is it possible for newly created files not yet in the repo… and not required (such as cache files)?

    Thank you for the tip :)

  4. Martin Says:

    EduBoris, if the file is not being tracked by git yet, just add it on .gitignore file. Thanks for this tip!

  5. Chris Burbridge Says:

    Thanks! Just what I was looking for.