git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git does not recognise directory named '${sys:DATA_ROOT_DIR}'

From
Taylor Blau <me@ttaylorr.com>
Date
Sep 3, 2019, 13:34 UTC
Message-ID
<20190903133422.GA51158@syl.lan>
In-Reply-To
<CAHMHMxW4-6AZEDaJU8KOy2kRSLXjdC_RTH528=nnhVLXh=ADUA@mail.gmail.com>
Hi,
On Tue, Sep 03, 2019 at 03:44:14PM +0300, Σταύρος Ντέντος wrote:
Show 30 quoted lines
> Hello there,
>
> While the name is obviously a mistake, git refuses to even acknowledge
> the directory.
>
> ```
> u@h:~/$ mkdir init-test
> u@h:~/$ cd init-test
> u@h:~/init-test$ git init
> Initialized empty Git repository in /home/u/init-test/.git/
> u@h:~/init-test$ (master #) mkdir \$\{sys\:DATA_ROOT_DIR\}/
> u@h:~/init-test$ (master #) git status
> On branch master
>
> No commits yet
>
> nothing to commit (create/copy files and use "git add" to track)
> u@h:~/init-test$ (master #) git add
> .git/                    ${sys:DATA_ROOT_DIR}/
> u@h:~/init-test$ (master #) git add \$\{sys\:DATA_ROOT_DIR\}/
> u@h:~/init-test$ (master #) git commit --signoff -m'a'
> On branch master
>
> Initial commit
>
> nothing to commit
> u@h:~/init-test$ (master #)
> ```
>
> Is that expected?

Git does not track empty trees; that is to say 'git add' on an empty directory does not change the status of the index.

Try for example:
  $ git init repo && cd repo
  $ mkdir -p dir
  $ git add dir
  $ git status
And note that 'git status' says there are no changes.

On the other hand, 'git add' performs fine even in a directory named '${sys:DATA_ROOT_DIR}'; simply create a file (even an empty one) within that directory and then run 'git add'. It will stage your "changes" as expected.

If you wish to keep this directory "empty", but stored in Git, a common convention is to create an empty '.gitkeep' file in the directory. This file is not special in any way to Git, rather it serves as _a_ file to keep the directory non-empty.

Hope this helps.
> Ντέντος Σταύρος

Thanks, Taylor

Previous: Σταύρος ΝτέντοςNext: Σταύρος Ντέντος
Message 2 of 6 in “Git does not recognise directory named '${sys:DATA_ROOT_DIR}'”
  1. Σταύρος ΝτέντοςSep 3, 2019
  2. Taylor BlauSep 3, 2019
  3. Σταύρος ΝτέντοςSep 3, 2019
  4. Philip OakleySep 3, 2019
  5. Junio C HamanoSep 3, 2019
  6. Σταύρος ΝτέντοςSep 3, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.