Live data from Hacker News

.gitignore Is Inherently Sisyphean

rgbcu.be

11–20 of 68 posts

Re: .gitignore Is Inherently Sisyphean

#12
No. IDE-specific ignore lists should go in $CONFIG/git or .git/info/exclude (or whatever the path is).

(git config --global core.excludesfile "$CONFIG/git/ignore")

.gitignore is committed to the repository and should be for files created by the repository that shouldn't appear in 'git status' like build/, etc.

Re: .gitignore Is Inherently Sisyphean

#13
This is a bad idea and if this seems necessary you are interacting with very low quality committers. People who don't even bother reading their own commits do not deserve to get their commits merged.

Also, that gitignore doesn't even work. man gitignore:

       •   An optional prefix "!" which negates the pattern; any
           matching file excluded by a previous pattern will become
           included again. It is not possible to re-include a file
           if a parent directory of that file is excluded. Git
           doesn’t list excluded directories for performance
           reasons, so any patterns on contained files have no
           effect, no matter where they are defined. [...]

Re: .gitignore Is Inherently Sisyphean

#15
Interesting. Makes sense for open source. In the workplace for those using common IDEs things like .vscode or .idea can definitely help with consistency or shared project setup. Each has docs which mention which files should or shouldn't be committed. Personally, I just use gitignore.io to generate the file based on my company's tooling and call it good enough.

Re: .gitignore Is Inherently Sisyphean

#16
post #7

I have never once experienced this problem. Mostly because I don't work with people who blindly commit everything without even looking once to see what's in their commit.

I use gitnr[1] to add fairly comprehensive `.gitignore` files to my repos at creation time.

Ultimately, it's the responsibility of each developer to determine whether or not the files they've added to their local clone really belong in source control! I've never encountered this issue, either, and I think I'd be unhappy working on a team where it was a serious problem.

That said, the whitelist approach does seem kinda interesting. It's really what should be present from the start, since Git had a manual staging process. But maybe this gap highlights a legit usabiiity issue. Maybe "add everything" plus an explicit, version-controlled whitelist is somehow easier or more intuitive than the "add nothing" default.

--

1: https://github.com/reemus-dev/gitnr

Re: .gitignore Is Inherently Sisyphean

#17
This isn't a terrible way to go about things. I normally add

  .*/
to the gitignore. Most crap I don't want is a hidden directory. It's easy to whitelist a few bad actors, and the gitignore stays pretty short.

Re: .gitignore Is Inherently Sisyphean

#19
post #17

This isn't a terrible way to go about things. I normally add .*/ to the gitignore. Most crap I don't want is a hidden directory. It's easy to whitelist a few bad actors, and the gitignore stays pretty short.

this really should be git's default, with a warning on git init .

They decided to waste the default warning with a wrist-slap for using "master"

Re: .gitignore Is Inherently Sisyphean

#20
post #2

Cool post. I highly suggest using templates from https://github.com/github/gitignore for your project as they tend to include a lot of files commonly found in them - eg .idea folders and so on.

Yes-anding this to say: For per-user gitignore, one can set the following config in ~/.gitconfig: # System-wide gitignore file # To avoid in-repo repetition for system-specifc garbage files [core] excludesfile = ~/.config/git/gitignore Then your file at ~/.config/git/gitignore can be a normal format, and not need to be stored in repo. Perfect for system files (.DS_Store...) or editor swap files etc.

great tip!
Post reply on HN