Problem: to add files at ./shells/smallApps/*
to Git at ./.git/
when I do not have the files at ./.git/info/exclude
nor at any .gitignore
-files.
This question is based on this tread where the problem is not solved completely.
I run
$git status ~/bin # On branch master nothing to commit (working directory clean) $git ls-files ~/bin Screen/dev/vim-open.screen --- cut ---
I note that I do not have the files "shells/smallApps/*" at my Git
$ls shells/smallApps/ ~/bin devTodo extract ~/bin
I want to add them to my Git by running
$git add shells/smallApps/devTodo shells/smallApps/extract fatal: Path 'shells/smallApps/devTodo' is in submodule 'shells/smallApps' $git add .
I note that the files are not added to my Git for some reason such that
$git status ~/bin # On branch master nothing to commit (working directory clean)
I do not have the files at .git/info/exclude nor at .gitignore -files.
What does the last warning mean?
This is because of some major drawbacks around git submodules, such as being locked to a specific version of the outer repo, the lacking of effective merge management, and the general notion that the Git repository itself doesn't really know it's now a multi-module repository.
Git submodules may look powerful or cool upfront, but for all the reasons above it is a bad idea to share code using submodules, especially when the code changes frequently. It will be much worse when you have more and more developers working on the same repos.
Git submodules allow you to keep a git repository as a subdirectory of another git repository. Git submodules are simply a reference to another repository at a particular snapshot in time. Git submodules enable a Git repository to incorporate and track version history of external code.
UPDATE
There are two general reasons why Git will ignore a file: gitignore
and submodules
.
To be more specific, the following conditions will cause Git to ignore a file when 'git add
' is invoked:
$GIT_DIR/exclude
..gitignore
file inside the repo..gitignore
file (specified by 'git config --global core.excludesfile
').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."
If the file is ignored, you can force it to be added with 'git add --force full/path/to/file
'.
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:
.gitmodules
file in your main repo..git/config
of your main repo.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.
.gitmodules
file..git/config
.git rm --cached path_to_submodule
(no trailing slash).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.
Caveat: If you want to keep these files (which you appear to want), you must manually remove the .git
directory from the submodule folder:
cd path_to_submodule
rm .git
cd ..
git add path_to_submodule
git status
git commit
UPDATE:
To assist debugging this issue, please post the output of the following complete session of commands:
cd to the top-level directory in your repo ls -al cat .git/config find . -name ".git*" git status git add editors git add shells git status
Based on the description of what you have done so far, I expect to see:
.gitmodules
file anywhere.git
directory (found at the root of your repo).git
directory in editors/vim/vimdoclet
.git
directory in shells/smallApps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With