Mastodon Skip to content
  • Home
  • Aktuell
  • Tags
  • Über dieses Forum
Einklappen
Grafik mit zwei überlappenden Sprechblasen, eine grün und eine lila.
Abspeckgeflüster – Forum für Menschen mit Gewicht(ung)

Kostenlos. Werbefrei. Menschlich. Dein Abnehmforum.

  1. Home
  2. Uncategorized
  3. Git won't track empty directories (because at heart it only tracks files).

Git won't track empty directories (because at heart it only tracks files).

Geplant Angeheftet Gesperrt Verschoben Uncategorized
18 Beiträge 15 Kommentatoren 0 Aufrufe
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • airtower@woem.menA airtower@woem.men

    @nedbat@hachyderm.io Another option that'd often (but maybe not always) be preferable: create the directory when it's needed, e.g. during build.

    jasonkarns@indieweb.socialJ This user is from outside of this forum
    jasonkarns@indieweb.socialJ This user is from outside of this forum
    jasonkarns@indieweb.social
    schrieb zuletzt editiert von
    #8

    @airtower love this.

    Versioning the empty dirs is a bandaid that addresses the symptom, not the root cause!!

    1 Antwort Letzte Antwort
    0
    • nedbat@hachyderm.ioN nedbat@hachyderm.io

      Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.

      EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.

      pipe_dreams@mk.absturztau.beP This user is from outside of this forum
      pipe_dreams@mk.absturztau.beP This user is from outside of this forum
      pipe_dreams@mk.absturztau.be
      schrieb zuletzt editiert von
      #9

      @nedbat@hachyderm.io yes. this.

      1 Antwort Letzte Antwort
      0
      • nedbat@hachyderm.ioN nedbat@hachyderm.io

        Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.

        EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.

        thatdnaguy@genomic.socialT This user is from outside of this forum
        thatdnaguy@genomic.socialT This user is from outside of this forum
        thatdnaguy@genomic.social
        schrieb zuletzt editiert von
        #10

        @nedbat I think I like this better. It at least gives you the ability to explain purpose instead of just hacking git to follow it.

        1 Antwort Letzte Antwort
        0
        • nedbat@hachyderm.ioN nedbat@hachyderm.io

          Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.

          EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.

          notmyname@mastodon.socialN This user is from outside of this forum
          notmyname@mastodon.socialN This user is from outside of this forum
          notmyname@mastodon.social
          schrieb zuletzt editiert von
          #11

          @nedbat @chrisjrn “This path is intentionally blank”

          1 Antwort Letzte Antwort
          0
          • nedbat@hachyderm.ioN nedbat@hachyderm.io

            Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.

            EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.

            kiloku@burnthis.townK This user is from outside of this forum
            kiloku@burnthis.townK This user is from outside of this forum
            kiloku@burnthis.town
            schrieb zuletzt editiert von
            #12

            @nedbat this feels so obvious and I never thought of it, so thanks for the tip. To be fair to myself, I only resorted to using a .gitkeep once ever

            1 Antwort Letzte Antwort
            0
            • doekman@mastodon.nlD doekman@mastodon.nl

              @nedbat But what do you do when all files from a folder are deleted in a certain commit. Leave a readme that this folder was once there for some kind of reason? Otherwise all people who once had pulled that commit end up with an empty folder that's not used for any thing...

              kiloku@burnthis.townK This user is from outside of this forum
              kiloku@burnthis.townK This user is from outside of this forum
              kiloku@burnthis.town
              schrieb zuletzt editiert von
              #13

              @doekman @nedbat if you don't expect the folder to be used anymore, delete the folder as well. In other words, if you can't write a justification for that folders existence in the readme, it doesn't need to exist

              1 Antwort Letzte Antwort
              0
              • nedbat@hachyderm.ioN nedbat@hachyderm.io

                Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.

                EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.

                lenalebt@ruhr.socialL This user is from outside of this forum
                lenalebt@ruhr.socialL This user is from outside of this forum
                lenalebt@ruhr.social
                schrieb zuletzt editiert von
                #14

                @nedbat
                One thing I started doing a few years ago is to add a .gitignore file that contains

                !.gitignore
                *

                Instead of the wildcard, you can also list the specific things you want to ignore. Of course, a few comments about why you ignore what or why this exists helps as well 😇.

                lenalebt@ruhr.socialL 1 Antwort Letzte Antwort
                0
                • nedbat@hachyderm.ioN nedbat@hachyderm.io

                  Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.

                  EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.

                  grishka@friends.grishka.meG This user is from outside of this forum
                  grishka@friends.grishka.meG This user is from outside of this forum
                  grishka@friends.grishka.me
                  schrieb zuletzt editiert von
                  #15

                  Better yet, make your project not rely on having an empty directory. If you need one, create it at runtime instead.

                  1 Antwort Letzte Antwort
                  0
                  • lenalebt@ruhr.socialL lenalebt@ruhr.social

                    @nedbat
                    One thing I started doing a few years ago is to add a .gitignore file that contains

                    !.gitignore
                    *

                    Instead of the wildcard, you can also list the specific things you want to ignore. Of course, a few comments about why you ignore what or why this exists helps as well 😇.

                    lenalebt@ruhr.socialL This user is from outside of this forum
                    lenalebt@ruhr.socialL This user is from outside of this forum
                    lenalebt@ruhr.social
                    schrieb zuletzt editiert von
                    #16

                    @nedbat
                    The gitignore serves then as both documentation and the replacement for .gitkeep

                    1 Antwort Letzte Antwort
                    0
                    • nedbat@hachyderm.ioN nedbat@hachyderm.io

                      Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.

                      EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.

                      ehproque@neopaquita.esE This user is from outside of this forum
                      ehproque@neopaquita.esE This user is from outside of this forum
                      ehproque@neopaquita.es
                      schrieb zuletzt editiert von
                      #17

                      @nedbat I just did just yesterday while debugging, and then added an ASCII cow because why not

                      1 Antwort Letzte Antwort
                      0
                      • nedbat@hachyderm.ioN nedbat@hachyderm.io

                        Git won't track empty directories (because at heart it only tracks files). Common advice is to add a '.gitkeep' file so the directory isn't empty and git will make the directory.

                        EVEN BETTER ADVICE: put a README in the directory explaining what the empty directory is for and what will eventually be there.

                        bunnyhero@timeloop.cafeB This user is from outside of this forum
                        bunnyhero@timeloop.cafeB This user is from outside of this forum
                        bunnyhero@timeloop.cafe
                        schrieb zuletzt editiert von
                        #18

                        @nedbat lol i did that for work once and was told to use .gitkeep instead 🙄

                        1 Antwort Letzte Antwort
                        0
                        • skorpy@chaos.socialS skorpy@chaos.social shared this topic
                        Antworten
                        • In einem neuen Thema antworten
                        Anmelden zum Antworten
                        • Älteste zuerst
                        • Neuste zuerst
                        • Meiste Stimmen



                        Copyright (c) 2025 abSpecktrum (@abspecklog@fedimonster.de)

                        Erstellt mit Schlaflosigkeit, Kaffee, Brokkoli & ♥

                        Impressum | Datenschutzerklärung | Nutzungsbedingungen

                        • Anmelden

                        • Du hast noch kein Konto? Registrieren

                        • Anmelden oder registrieren, um zu suchen
                        • Erster Beitrag
                          Letzter Beitrag
                        0
                        • Home
                        • Aktuell
                        • Tags
                        • Über dieses Forum