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

Re: What's the use case for committing both the freshly created file and it's exclusion in .gitignore?

From
BKBartosz Konikiewicz <izdwuut@gmail.com>
Date
Aug 10, 2018, 10:19 UTC
Message-ID
<CAAdU=LuXh6jo+pDPE-tisd_SoMhGjGL6kvm6X91Qsz1-XYD0wA@mail.gmail.com>
In-Reply-To
<20180810011249.GA82458@aiede.svl.corp.google.com>
On 9 August 2018 at 21:58, Jeff King <peff@peff.net> wrote:
Show 6 quoted lines
> If you are asking as a more general case: why do we not complain about
> .gitignore for files the index already knows about, then I think that is
> useful. It lets you override the .gitignore _once_ when adding the file
> initially, and then you don't have to deal with it again (and keep in
> mind that the pattern excluding it may be broad, like "*.o", or even
> just "*", so simply deleting it from the .gitignore is not an option).
This totally makes sense to me. Thanks for your explaination!
On 10 August 2018 at 03:12, Jonathan Nieder <jrnieder@gmail.com> wrote:
> "git help gitignore" has some notes about this.

Thanks! I wasn't aware of this. For some peculiar reason it didn't strike me that the most appropriate place to look for .gitignore-related stuff is - lo and behold - .gitignore manual page. I was looking for clarification on 'git add' page, which I didn't find informative enough in that aspect.

> If you have ideas
> about moments in interactive use where we could print some messages to
> make the behavior less surprising, that would be very welcome.
Sure I do! I have came up with two ideas which I believe that can be combined:
1.
Show 10 quoted lines
>            staged     unstaged path
>   1:    unchanged        +1/-0 .gitignore !
>   2:        +0/-0      nothing excluded.txt
>
> ! Not ignoring yet untracked files.
>
> *** Commands ***
>   1: status       2: update       3: revert       4: add untracked
>   5: patch        6: diff         7: quit         8: help
> What now>

Here I propose to add an exclamation mark next to a .gitignore file and reference it below. I am also thinking about marking files that .gitignore affects. I think that any special character would be appropriate. If I may only suggest, I wouldn't choose an asterisk (*) because it's already used when a '2: update' option is chosen.

2.
Show 11 quoted lines
>            staged     unstaged path
>   1:    unchanged        +1/-0 .gitignore
>   2:        +0/-0      nothing excluded.txt
>
> *** Commands ***
>   1: status       2: update       3: revert       4: add untracked
>   5: patch        6: diff         7: quit         8: help
> What now> q
> You are about to add new files that are excluded in .gitignore. Confirm y/n?
> What now>y
> Bye.

Here I ask the user to confirm that he is about to stage yet untracked files. Then I cheer him up with Git built-in courtesy.

Previous: Jonathan NiederNext: brian m. carlson
Message 4 of 5 in “What's the use case for committing both the freshly created file and it's exclusion in .gitignore?”
  1. Bartosz KonikiewiczAug 9, 2018
  2. Jeff KingAug 9, 2018
  3. Jonathan NiederAug 10, 2018
  4. Bartosz KonikiewiczAug 10, 2018
  5. brian m. carlsonAug 10, 2018

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.