‹ BackHN Continuity

Thread

Two Git ignore files nobody told me about

95 points · 66 comments · faithraven

  1. ktm5j · · focus · HN ↗
    Just a nit-pick, but some/repo/path/.gitignore isn't necessarily committed to the repo. For example, if your repo has no .gitignore file, you can totally add one in your clone without adding it to the tree. Of course then you can't do something like `git add .` without committing it.

    Also `~/.gitignore` works as a global gitignore. I usually stick something like `katie*` in there so I can copy some `script.sh` to `katie_script.sh` and then I can make changes that I don't want to commit.

    Quick edit: I'm not sure `~/.gitignore` works out of the box.. looks like I stuck that in my `~/.gitconfig` for excludesfile

    1. nom · · focus · HN ↗
      you can add .gitignore to .gitignore ;)
      1. ktm5j · · focus · HN ↗
        True! But a gotcha there is that if your repo does have a .gitignore in the tree then this trick won't work. I had a coworker try to do just that and we were all pretty confused when his changes kept getting committed. `git add ./` will stage changes to any file in the commit tree, even if that file matches a line in gitignore.
      2. spider-mario · · focus · HN ↗
        In fact tup does exactly that to the .gitignores it generates.
      3. [deleted] · · focus · HN ↗

        [deleted]

      4. sinabis · · focus · HN ↗
        yes, that works perfectly
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.