git add fails silently when adding files in subfolders which contain their own repositories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
repository.
        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:
        hint: git submodule add <url> dir
        hint:
        hint: If you added this path by mistake, you can remove it from the
        hint: index with:
        hint:
        hint: git rm --cached dir
        hint:
        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]
post-commit
post-checkout
post-merge
pre-push



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux