list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Tom Piercy <>
Subject: git add fails silently when adding files in subfolders which contain their own repositories
Date: Thu, 19 Nov 2020 16:35:26 +0000	[thread overview]
Message-ID: <> (raw)

Thank you for filling out a Git bug report
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)

1. Create a new repository in a new folder:
    a. mkdir gittest
    b. cd gittest
    c. git init
2. Create a subfolder and a new repository inside the subfolder (all
inside the gittest directory)
    a. mkdir dir
    b. cd dir
    c. git init
3. Create a file in the subdirectory and try to add it to the first
repository (starting inside gittest/dir)
    a. touch file
    b. cd ..
    c. git add dir/file
4. Observe status of file
    git status

What did you expect to happen? (Expected behavior)
    The files to be added to the main repository or an error message

What happened instead? (Actual behavior)
    git add dir/file runs and completes. However the file is not
staged. There is no output.

    Running the command git add dir/ (where dir is a folder containing
the second git repository) produces the warning:

        error: 'dir/' does not have a commit checked out
        fatal: adding files failed

    If the repository in the subfolder has at least 1 commit the
following warning will be printed:
        warning: adding embedded git repository: dir
        hint: You've added another git repository inside your current
        hint: Clones of the outer repository will not contain the contents of
        hint: the embedded repository and will not know how to obtain it.
        hint: If you meant to add a submodule, use:
        hint: git submodule add <url> dir
        hint: If you added this path by mistake, you can remove it from the
        hint: index with:
        hint: git rm --cached dir
        hint: See "git help submodule" for more information.

    After the warning git status displays:
    gittest % git status
        On branch master

        No commits yet

        Changes to be committed:
          (use "git rm --cached <file>..." to unstage)
        new file: dir

        Changes not staged for commit:
          (use "git add <file>..." to update what will be committed)
          (use "git restore <file>..." to discard changes in working directory)
          (commit or discard the untracked or modified content in submodules)
        modified: dir (untracked content)

    Deleting the .git folder in the subdirectory allows the git add
command to complete correctly

What's different between what you expected and what actually happened?
    The files are not added and there is no explanation why they are not.

Anything else you want to add:
    Deleting the .git folder in the subdirectory allows the git add
command to complete correctly

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.

[System Info]
git version:
git version 2.29.2
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Darwin 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45
PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64
compiler info: clang: 12.0.0 (clang-1200.0.32.27)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/zsh

[Enabled Hooks]

                 reply	other threads:[~2020-11-19 16:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \
    --subject='Re: git add fails silently when adding files in subfolders which contain their own repositories' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).