Issue committing git repository - warning: adding embedded git repository: lib/cf

I’m trying to commit the initial project directory nitrogen created. However some directories in the lib directory can’t be added for example:

ookma@MSI MINGW64 /e/ookma-kyi (master)
$ git add *
warning: adding embedded git repository: lib/cf
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> lib/cf
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint:   git rm --cached lib/cf
hint:
hint: See "git help submodule" for more information.

What is the proper procedure for committing a nitrogen project?

Update:

Getting stuck at:

Changes not staged for commit:
(use “git add …” to update what will be committed)
(use “git restore …” to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: lib/fs (untracked content)
modified: lib/mimetypes/ (untracked content)
modified: lib/qdate/ (untracked content)
modified: lib/qdate_localtime/ (untracked content)

Removing it via rm -f --cached I get stuck at

> 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:   lib/mimetypes/ (untracked content)
>         modified:   lib/qdate/ (untracked content)
>         modified:   lib/qdate_localtime/ (untracked content)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        lib/fs/
        lib/mimetypes/
        lib/qdate/
        lib/qdate_localtime/

Readding lib/fs:

$ git add lib/fs
warning: adding embedded git repository: lib/fs
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> lib/fs
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint:   git rm --cached lib/fs
hint:
hint: See "git help submodule" for more information.

I am basically stuck on a loop. :face_with_symbols_over_mouth:

3 Likes

Update:

I just did some more research this morning and noted there are git repositories in the afflicted library folders.

image

image

I have not seen this before, is it normal?

1 Like

Hello @Ookma-Kyi, your problem can easily be solved by adding lib/* on a new line in the .gitignore file located in the root directory of your project.

Basically when you initialise a git repository and then run git add ., git will want to track every single file in that directory (including subdirectories). But, projects will always have numerous, or at-least some, files we would rather not track. So we include the names of such files and directories in .gitignore to tell git “Hey Mr. Man, I beg you not to track these files”.

Since you’re on nitrogen, just copy the content of this file and paste it in your .gitignore file. You may also want to have a look at this .gitignore template; probably after going deeper into Erlang and doing some more reading about git like here for example.

3 Likes

Are submodules or a dependency acquire setup or something? You still want it to build when you do a fresh git clone after all.

3 Likes

That’s the thing, I have used git before with subdirectories and sub-subdirectories and never encountered this type of setup. What are submodules or “dependency acquire”? Are you talking about the rebar 2/3 dependency manager?

3 Likes

In this case, the submodules are just dependencies that are pulled by rebar. Following @lgmfred’s advice to copy that .gitignore file should help. You do not need to add any of the files in lib to your git repo - rebar will automatically pull them if they don’t exist.

3 Likes

I’ve updated both the default .gitignore and the merge-configs script in the default windows installation, so if you pull from master, it’ll give fewer issues.

3 Likes

I used the instructions provided by @lgmfred here and installed the Git For Windows SDK. How do i update my Nitrogen installation?

3 Likes

Basically, you can just download https://raw.githubusercontent.com/nitrogen/nitrogen/master/rel/overlay/common/.gitignore and replace that same file in the root of your generated installation.

You’ve already replaced the merge-configs file, so that should be good to go.

For future generated projects, you could just do git pull from your nitrogen directory.

3 Likes