Please make sure that the gitmodules file is in the working tree
Please make sure that the gitmodules file is in the working tree
Please make sure that the gitmodules file is in the working tree
Check your version of git by running
SYNOPSIS
DESCRIPTION
In addition, there are a number of optional keys:
Defines the default update procedure for the named submodule, i.e. how the submodule is updated by the git submodule update command in the superproject. This is only used by git submodule init to initialize the configuration variable of the same name. Allowed values here are checkout, rebase, merge or none. See description of update command in git-submodule[1] for their meaning. For security reasons, the !command form is not accepted here.
Defines under what circumstances git status and the diff family show a submodule as modified. The following values are supported:
The submodule will never be considered modified (but will nonetheless show up in the output of status and commit when it has been staged).
All changes to the submodule’s work tree will be ignored, only committed differences between the HEAD of the submodule and its recorded state in the superproject are taken into account.
Only untracked files in submodules will be ignored. Committed differences and modifications to tracked files will show up.
No modifications to submodules are ignored, all of committed differences, and modifications to tracked and untracked files are shown. This is the default option.
When set to true, a clone of this submodule will be performed as a shallow clone (with a history depth of 1) unless the user explicitly asks for a non-shallow clone.
NOTES
EXAMPLES
Я новичок в git, в настоящее время рассматриваю портирование некоторых крупных проектов из mercurial. У нас есть корневой проект, который просто содержит ссылки на все внешние проекты (подмодули в git). Я пытаюсь воссоздать это в git.
Я импортировал проект (foo) в gitib. Я создал новый пустой проект (root) и клонировал его локально. Я хочу добавить Foo в качестве подмодуля, используя
из /c/Work/GitHub/root (мастер)
Что я делаю неправильно?
РЕДАКТИРОВАТЬ: я тоже пробовал.
Я получаю ту же ошибку.
Это означает, что либо файл существует локально, либо его нет в промежуточной области или в текущей HEAD фиксации.
Жесткий сброс, например, до последней фиксации или фиксации всех изменений, решил проблему для меня.
Я думаю, что в этом случае сообщение должно быть чем-то вроде «сначала зафиксируйте свои изменения» или около того.
There was something wrong with my git installation. I uninstalled and reinstalled it the error went away.
Учитывая, что текущая версия git-submodule.sh не работает:
Обратите внимание, что это немного изменится с Git 2.33 (3 квартал 2021 г.) с переписыванием » git submodule » ( man ) на C, что действительно влияет git submodule add :
submodule : prefix die messages with ‘fatal’
Signed-off-by: Atharva Raykar
Mentored-by: Christian Couder
Mentored-by: Shourya Shukla
The standard die() function that is used in C code prefixes all the messages passed to it with ‘fatal: ‘.
This does not happen with the die used in ‘git-submodule.sh’.
Let’s prefix each of the shell die messages with ‘fatal: ‘ so that when they are converted to C code, the error messages stay the same as before the conversion.
Note that the shell version of die exits with error code 1, while the C version exits with error code 128. In practice, this does not change any behaviour, as no functionality in ‘submodule add’ and ‘submodule update’ relies on the value of the exit code.
submodule—helper : introduce add-clone subcommand
Signed-off-by: Atharva Raykar
Mentored-by: Christian Couder
Mentored-by: Shourya Shukla
Based-on-patch-by: Shourya Shukla
Based-on-patch-by: Prathamesh Chavan
Helped-by: Đoàn Trần Công Danh
Let’s add a new » add-clone » subcommand to git submodule—helper with the goal of converting part of the shell code in git-submodule.sh related to git submodule add (man) into C code.
This new subcommand clones the repository that is to be added, and checks out to the appropriate branch.
This is meant to be a faithful conversion that leaves the behavior of ‘ cmd_add() ‘ script unchanged.
I’m new to git, currently looking at porting some large projects from mercurial. We have a root project that just contains the references to all the external projects (submodules in git). I’m trying to recreate this in git.
I have imported a project (foo) into githib. I’ve created a new empty project (root) and cloned it locally. I want to add Foo as a submodule using
from the /c/Work/GitHub/root (master)
What I’m I doing wrong?
EDIT: I’ve also tried.
I get the same error.
5 Answers 5
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
This means that either the file exists locally, or it doesn’t exist in the staging area or the current HEAD commit.
Hard reset e.g. to the last commit or committing all the changes solved the problem for me.
I think the message should be in this case something like «commit your changes first» or so.
There was something wrong with my git installation. I uninstalled and reinstalled it the error went away.
Considering the current version of git-submodule.sh fails on:
Note that this will slightly change With Git 2.33 (Q3 2021), with the rewrite of » git submodule » (man) in C, which does impact git submodule add :
submodule : prefix die messages with ‘fatal’
Signed-off-by: Atharva Raykar
Mentored-by: Christian Couder
Mentored-by: Shourya Shukla
The standard die() function that is used in C code prefixes all the messages passed to it with ‘fatal: ‘.
This does not happen with the die used in ‘git-submodule.sh’.
Let’s prefix each of the shell die messages with ‘fatal: ‘ so that when they are converted to C code, the error messages stay the same as before the conversion.
Note that the shell version of die exits with error code 1, while the C version exits with error code 128. In practice, this does not change any behaviour, as no functionality in ‘submodule add’ and ‘submodule update’ relies on the value of the exit code.
submodule—helper : introduce add-clone subcommand
Signed-off-by: Atharva Raykar
Mentored-by: Christian Couder
Mentored-by: Shourya Shukla
Based-on-patch-by: Shourya Shukla
Based-on-patch-by: Prathamesh Chavan
Helped-by: Đoàn Trần Công Danh
Let’s add a new » add-clone » subcommand to git submodule—helper with the goal of converting part of the shell code in git-submodule.sh related to git submodule add (man) into C code.
This new subcommand clones the repository that is to be added, and checks out to the appropriate branch.
This is meant to be a faithful conversion that leaves the behavior of ‘ cmd_add() ‘ script unchanged.
Git will not init/sync/update new submodules
The second submodule ( external/pyfacebook ) was added by another developer in a feature branch. I’ve inherited the development now, and have checked out the feature branch. However, Git will not pull the submodule for me. I’ve tried:
21 Answers 21
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
Then commit it to record the ID properly.
Adding some further comments to this working answer: If the git submodule init or git submodule update does’nt work, then as described above git submodule add url should do the trick. One can cross check this by
Had the same issue, when git ignored init and update commands, and does nothing.
HOW TO FIX
If that requirements met, it will work. Otherwise, all commands will execute without any messages and result.
If you did all that, and it still doesn’t work:
My local git version 2.22.0 as of this writing.
IMPORTANT
git submodule add company/project.git includes/project is required (when adding the module for the first time), this will:
Also for reference see:
There seems to be a lot of confusion here (also) in the answers.
EDIT
This means the submodules haven’t been set up correctly and a git submodule add command will have to be executed. A detailed explanation of how submodules work:
If submodules were not added correctly:
What does git submodule add do?
When a repo with submodules has been set up correctly and someone has already performed a git submodule add command, the command has done the following things:
You can then proceed by doing:
will show the submodules present in the tree and their corresponding commit hash code, can serve as an initial check to see which submodules are expected
git submodule init
git submodule update
same as update but sets the submodule to the latest commit on the branch available by the remote repo, similar as going in each submodule’s folder afterwards and do a git pull
which is all of the above combined.
Unable to track files within Git submodules
This question is based on this tread where the problem is not solved completely.
I note that I do not have the files «shells/smallApps/*» at my Git
I want to add them to my Git by running
I note that the files are not added to my Git for some reason such that
What does the last warning mean?
3 Answers 3
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
UPDATE
To be more specific, the following conditions will cause Git to ignore a file when ‘ git add ‘ is invoked:
Forcing ‘ git add ‘ on an ignored file:
You can check to see if a particular file is ignored by invoking ‘ git add full/path/to/file ‘.
The man page states that «If an ignored file is explicitly specified on the command line, the command will fail with a list of ignored files.»
Instructions to eliminate a submodule reference:
As noted in a previous answer, shells/smallApps is a submodule in your repository.
If the file is part of a submodule, the situation is more complex. You cannot modify the contents of the submodule from within the main project.
If you want to eliminate the submodule reference and directly track the files in your main repo, there are several steps that must be performed. You cannot simply remove the «.git» directory from the submodule. There are three links between your main repository and the submodule:
Per this related SO question, you need to perform the following steps to completely remove the sub-module:
NOTE: If another branch depends on this submodule, then removing it can corrupt your repository! This is a dangerous operation. use with caution.
The files that were part of the submodule are now untracked and you may decide to keep or delete them as desired (with the one caveat mentioned below).
If you don’t need these files, you may simply delete them.
UPDATE:
Request for further information:
To assist debugging this issue, please post the output of the following complete session of commands:
Based on the description of what you have done so far, I expect to see:
Источники информации:
- http://www.stackfinder.ru/questions/62018647/get-please-make-sure-that-the-gitmodules-file-is-in-the-working-tree-when-run
- http://stackoverflow.com/questions/62018647/get-please-make-sure-that-the-gitmodules-file-is-in-the-working-tree-when-run
- http://stackoverflow.com/questions/3336995/git-will-not-init-sync-update-new-submodules/44051753
- http://stackoverflow.com/questions/1084969/unable-to-track-files-within-git-submodules




