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

Re: gitignore vs. exclude vs assume-unchanged?

From
Andrew Ardill <andrew.ardill@gmail.com>
Date
Apr 22, 2014, 00:40 UTC
Message-ID
<CAH5451k+GGGdHXkwne2O-h2m2AyWg7K+5reNRG64+eF891pVUA@mail.gmail.com>
In-Reply-To
<4dd8389939fbf3dc77b58adcca7b17c1@bellandwhistle.net>
On 18 April 2014 10:36,  <alex@bellandwhistle.net> wrote:
> "Like the $GIT_DIR/info/exclude file, gitignore files specify intentionally
> untracked files that Git should ignore. The difference is that files matched
> by a pattern in a gitignore file will be untracked for all users of the
> repository."

As a data point, I have seen people add ".gitignore" to their .gitignore file, as they don't want to share the file.

This seems like a misuse of the functionality, as $GIT_DIR/info/exclude is a better choice for the same use case, but I'm not sure why the misuse is there.

My guess is that users aren't aware of excludes, whilst gitignore is placed front of mind living at the root of many repositories. Education will help here, but is there any way to make the 'correct' way more intuitive?

It would be possible to check for this antipattern during normal use and provide a hint to the user, but that is probably too heavy handed and might annoy people with a legitimate use case. For that matter, if the gitignore file is easier to use for the 'private ignore' use case we have a bigger problem and shouldn't dictate to users what to use.

As to the documentation, it is already quite comprehensive. All exclusion methods are listed, and the reasons for why to use them are well laid out. The introduction does specifically mention 'gitignore' files, but that seems to be due to all the ignore files ($HOME/.config/git/ignore, $GIT_DIR/info/exclude, .gitignore) being classified as 'gitignore' files.

So some possible improvements. We could replace 'gitignore' with 'git ignore' in instances where we are referencing all forms of the ignore file, not just the .gitignore file.

"Git ignore files specify intentionally untracked files that Git should ignore."

We could reference the multiple ignore locations earlier, for people who don't read past the first paragraph of to documentation.

"Git ignore files specify intentionally untracked files that Git should ignore. A git ignore file can be specified for all local repositories, a specific local repository, or shared with other users of a repository. Files already tracked by Git are not affected; see the NOTES below for details."

Finally, it's a little confusing that one of the files is called 'exclude'.

It would be great to rename it to 'ignore'; $GIT_DIR/info/exclude -> $GIT_DIR/info/ignore. Is there any reason this shouldn't be done? I haven't checked how extensive a change this would need be, but it would make the usage much more consistent. The only reference I have found to this file is at http://markmail.org/message/l7shxticxo3kzdpn from Junio in a discussion around an RFD for ignore rules.

I think these three changes together would make the intended usage more obvious to both new and old users, though each change could stand on its own as well.

Regards,
Andrew Ardill
Previous: alex@bellandwhistle.netNext: Junio C Hamano
Message 6 of 10 in “gitignore vs. exclude vs assume-unchanged?”
  1. alex@bellandwhistle.netApr 16, 2014
  2. Junio C HamanoApr 16, 2014
  3. alex@bellandwhistle.netApr 16, 2014
  4. Jonathan NiederApr 16, 2014
  5. alex@bellandwhistle.netApr 18, 2014
  6. Andrew ArdillApr 22, 2014
  7. Junio C HamanoApr 22, 2014
  8. alex@bellandwhistle.netApr 25, 2014
  9. luc.linux@mailoo.orgApr 26, 2014
  10. ZéApr 26, 2014

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.