• NostraDavid@programming.dev
    link
    fedilink
    arrow-up
    9
    ·
    edit-2
    1 day ago

    I prefer to flip the logic of the .gitignore.

    # ignore root files/folders
    /*
    
    # unignore files
    !.gitignore
    !README.md
    !Justfile
    !flake.nix
    !flake.lock
    !pyproject.toml
    !.python-version
    !uv.lock
    
    # unignore folders
    !src/
    !docs/
    
    # reignore (recursively)
    __pycache__
    

    This includes the files and folders (and their subfiles/folders), while recursively ignoring any pycache bullshit.

    • Small
    • Maintainable
    • Easy to change
    • Readable
  • talkingpumpkin@lemmy.world
    link
    fedilink
    arrow-up
    11
    ·
    1 day ago

    There’s also .git/info/exclude, which is a per-repo local (untracked) .gitignore.

    You can even add more ignore files via configuration (I don’t recall how).

  • JakenVeina@midwest.social
    link
    fedilink
    arrow-up
    13
    ·
    2 days ago

    Anyone else dislike the idea? Like, having ignore patterns be ported automatically to everyone that wants to clone the repo just seems… always better than making people do it themselves. At basically no cost.

    • Caveman@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      2 hours ago

      I actually like it a lot for stuff that is user specific, not repo specific. I imagine someone could have a “build.log” to view the build output in some specific way that hooks up to a mini taskbar app or some other random shit.

      I’ve personally added some files that don’t relate to the project at all and has no reason for being inside a .gitignore and I’ve had to add it many times.

    • hallettj@leminal.space
      link
      fedilink
      English
      arrow-up
      10
      ·
      1 day ago

      Global gitignore is for idiosyncrasies of your computer, not for repo-specific stuff. For example if you use an editor that writes in-place backup or swap files (like .swp files with Vim’s default settings), or you’re on a Mac which writes .DS_Store files into every directory, you’re going to want those ignored for every repo. That way you can comfortably work with other people’s repos, even if they’re not configured for your particular setup.

      The global ignore combines with gitignore files in each repo. So if it’s an ignore pattern that everyone working with that repo should have, put it in the repo.

    • CombatWombatEsq@lemmy.worldOP
      link
      fedilink
      arrow-up
      12
      ·
      2 days ago

      I really like the global gitignore. I get annoyed when people check in files that are specific to their particular text editor, so I recommend to new contributors adding anything that is specific to their IDE or text editor to their global gitignore so I don’t have to have a bunch of vim and emacs and vs code and atom and webstorm and who even knows what other stuff in my project gitignore.

      • Jayjader@jlai.lu
        link
        fedilink
        arrow-up
        5
        ·
        1 day ago

        I have the same preference for personal projects, but when I was working on a corporate team it was really useful to have the “run configs” for intellij checked in so that each new team member didn’t need to set them up by themselves. Some of the setup needed to get the python debugger properly connected to the project could get quite gnarly.

        • CombatWombatEsq@lemmy.worldOP
          link
          fedilink
          arrow-up
          2
          ·
          21 hours ago

          +1 for checking in your config when you can mandate everyone uses the same tool chain. My point is more that the existence of global gitignore supports my open-source use case without precluding your corporate use case.

        • hallettj@leminal.space
          link
          fedilink
          English
          arrow-up
          2
          ·
          1 day ago

          Gitignore settings don’t prevent checking in run configs if that’s what you want to do. Even if someone has the run configs pattern ignored, they’ll get those files with the repo clone. Gitignore only prevents adding files that aren’t already checked in - it’s a guard rail to prevent accidentally checking in so something you don’t want. You can override ignore settings to check in something new in with git add --force <filename>

      • JakenVeina@midwest.social
        link
        fedilink
        arrow-up
        8
        ·
        2 days ago

        shrug To each their own, I guess.

        I can definitely appreciate that opinion, I just… disagree. I don’t really give 2 shits about a file having some stuff in it that I don’t personally use, so long as it still has a purpose. I.E. I’ll take a little clutter in a file like that, that basically never gets looked at or edited, over the chance of cluttering up the repo itself, or PRs, or history with stuff that has no purpose at all.

    • zygo_histo_morpheus@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      1 day ago

      If you’re contributing to a larger project, it might not be trivial to modify the .gitignore file, because you might have to go through a review process and so on. It might be easier to just ignore something locally.

  • entwine@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    1 day ago

    Completely off topic, but

    Unfortunately, I didn’t check that before monkeying with things, so I have no idea if I’ve changed my system accidentally.

    Reading this makes me feel so powerful to be as familiar as I am with podman/docker (which to be clear is a modest amount). Just do:

    podman run --rm -it debian:latest bash
    

    Then apt install git, check those folders, and finally exit so the entire container gets automatically deleted.

    The whole thing is done in a few seconds (or more depending on how long git takes to download and whether the debian image is already cached)

    Everyone on Linux should have this in their toolbelt.

      • entwine@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        5 hours ago

        The solution to the problem is to install git into a clean system so you can observe what changes it makes.

        How would you do this with Nix?

        • ultimate_worrier@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          1 hour ago
          nix-shell -p git
          

          Or some even fancier ones:

          nix-store -qR $(nix-build '<nixpkgs>' -A git --no-out-link)
          

          or this command (which nix people avoid generally because it creates files outside of the store):

          nix path-info -rSh $(nix-build '<nixpkgs>' -A git --no-out-link)
          

          or

          nix-env -p /tmp/clean-profile -iA nixpkgs.git && nix-store -qR /tmp/clean-profile
          
          
          # then
          
          rm /tmp/clean-profile* 
          
          # to get rid of the temp files
          
          
          • entwine@programming.dev
            link
            fedilink
            arrow-up
            1
            ·
            1 hour ago

            I guess you misunderstood my question, because that won’t work. nix-shell -p git doesn’t provide an isolated operating system. They only isolate programs and libraries. If your native git installation modified something in your home folder, those changes will still be visible inside a nix shell.

            I’m not sure what you’re trying to accomplish in those other commands, as they just seem to print out git’s dependencies?

            Also, I see you’re actively editing your comment as I’m typing so sorry if you actually post the answer after I hit Reply.