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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9 August 2018 at 21:58, Jeff King <peff@xxxxxxxx> wrote:
> 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@xxxxxxxxx> 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.
>            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.
>            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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux