20

What are your feelings on committing your .gitignore file to the repo? I argue that you SHOULD commit the .gitignore file because you are much less likely to accidentally commit things you don't want.

My team lead just told me that he doesn't want the .gitignore file in the repo because it's not part of the build.

Comments
  • 10
    I have never met someone who would argue against this, I find it really weird that someone wouldn't want to have it in

    We have a .dockerignore to prevent it from getting into the build, and even if it did get in, we have some bytes to spare
  • 9
    Your team lead needs to not be a team lead. That is a terrible policy.
  • 8
    You can have a gitignore file in any directory if you want. But IMO one in the root directory of the repo is an absolute must. It holds the global ignores for that repo, the ones no dev should handle more than once (when he puts 'em into the gitignore).

    If one has some special habits that needs ignoring, every dev can build up a personal gitignore in his home directory.

    Having everyone handle their own ignore files for everything is just a waste of time.
  • 3
    @ddephor especially if a dev doesn't know there's a new directory that has to be ignored and boom, 500 junk files committed
  • 7
    Yeah, don't commit the .gitignore for your node project, then sit back and watch some dick wad clone the project, make some changes and push node_modules to the repo.
  • 3
    @nibor That's exactly what's going to happen. This is a React app. At least I'm only here for 2 more months
  • 0
    Make a poll to count what people think of this policy.
    Options: good, bad, indifferent, retarded.

    Post on Twitter under a fake account. Follow at least 400 devs. And wait for the results.

    If you post the link here, I'd vote.

    After having results, just share it to a bunch of co-workers and see if someone has the audacity to show the team lead.

    Or just state your ground and commit the .gitignore file.
  • 0
    If you add .gitignore to your .gitignore does it still enforce it but also not allow you to push changes to it?
  • 2
    @bkwilliams I THINK that if it's already tracked and part of the repo, then you add .gitignore to it, then it will still update because it's already tracked.
  • 3
    Your team lead is an idiot, show him this thread
  • 4
    I once had to explain to a team lead that committing compiled CSS was a bad idea and that it should be ignored and compiled one in the production server. He argued that we shouldn't have to do that on the server (no ci server either) and then would keep wondering why everybody would have merge conflicts on the CSS file.
  • 1
    @psion1369 what the fuck is your colleague even doing
  • 3
    @psion1369 is murder legal in your country?

    Imagine a dev forgetting to compile the css and then deploying to prod...
  • 1
    looks like you are using subversion, right?
  • 1
    Not committing it seems a really odd practice and a very nice way to mess up thing. And besides, the reasoning behind it it's, to say the least, faulty. In the .gitignore file you'll probably will have files that you don't want in your build/repo (e.g. keys), so not committing it might cause such files ending up in the build/repo, which is likely more dangerous than having a .gitignore file pushed to "origin"
  • 0
    Tell him “do you want a .gitignore which is a few kb large or a multi-gb node_modules folder which will inevitably by pushed by mistake at some point?”
  • 1
    @kescherRant @alexbrooklyn it was even worse. He refused to learn git on the command line, insisted that the GUI tools he always cycled through were the better options. Every month he was installing a new GUI when the rest of the team switched to cli and managed to stay there.
  • 0
    @ybautista Agreed, I only use my IDE's conflict resolver for git related stuff, the rest is all cli :D
  • 0
    .gitignore should definitely be part of the repo. To say that it shouldn't be part or the codebase is ridiculous at minimum because the codebase is hosted in a git repo... And there's always a minimal configuration required that everyone should share, so what? He's gonna send it over email to everyone? Or just wait for a mistake to happen so he can then flex his ego about how stupid they were for making a mistake? Bad Lead
  • 0
    I wonder if you told your lead to .gitignore the .gitignore file and commit that 🤔
  • 0
    @halfflat

    Okay, but what about subdirectories like "build"? They should not be included!
  • 0
    @halfflat putting effort into not using `git add .` ?! Impossible
  • 0
    @halfflat

    If I ever find out who you are and work with you, I'mma add node_modules to the repo intentionally.
Add Comment