git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: ignoring files/directories in git

From
Alex Riesen <raa.lkml@gmail.com>
Date
Sep 21, 2008, 17:20 UTC
Message-ID
<20080921172048.GA3877@blimp.localhost>
In-Reply-To
<19596152.post@talk.nabble.com>
mwolfe38, Sun, Sep 21, 2008 18:54:01 +0200:
Show 18 quoted lines
> In my project I have several directories I do not want to have git ignore.
> One of them being
> cache/ and the other log/
> I've added them to the .gitignore file which I have in the initial directory
> of the repository
> The contents of my gitignore are:
> 
> .settings
> .cache
> cache/
> log/
> .project
> 
> However, if I do 
> git add .
> It will add the files from cache and log anyways.
> I know git add . will add anything that hasn't been added but shouldn't it
> ignore files in .gitignore?
It should and indeed it does ignore them:
    $ mkdir ggg && cd ggg
    $ git init
    Initialized empty Git repository in /tmp/ggg/.git/
    $ >a
    $ mkdir cache log
    $ touch cache/b
    $ touch log/c
    $ echo cache/ >.gitignore
    $ echo log/ >>.gitignore
    $ cat .gitignore
    cache
    log
    $ git add .
    $ git ls-files
    .gitignore
    a

What is your git version and where have you got it from? Is your .gitignore written exactly like this (case, some hidden extension, like they do on Windows)? Any invisible characters in .gitignore?

Previous: Boaz HarroshNext: mwolfe38
Message 3 of 12 in “ignoring files/directories in git”
  1. mwolfe38Sep 21, 2008
  2. Boaz HarroshSep 21, 2008
  3. Alex RiesenSep 21, 2008
  4. mwolfe38Sep 21, 2008
  5. Tim HarperSep 22, 2008
  6. Dmitry PotapovSep 21, 2008
  7. mwolfe38Sep 22, 2008
  8. Boaz HarroshSep 22, 2008
  9. Dmitry PotapovSep 22, 2008
  10. Boaz HarroshSep 22, 2008
  11. Andreas EricssonSep 22, 2008
  12. Dmitry PotapovSep 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.