Git - Bitbucket repo hasnt stored the files in a s

2019-06-07 15:38发布

问题:

I have a repo on Bitbucket. I just noticed, it has not stored a particular sub-folder I added later.

Upon noticing, I tried to run the commands:

git add *

(didnt add the sub-folder)

git add (folder path)

(still no affect)

My .gitignore is empty

How can I add the files to the repo?

On the repo, I have the directory & files showing as (i.e. the files are mere references, not clickable):

回答1:

If your repo does not have a .gitmodules file, then those not-clickable references are nested git repo whose gitlink (special entry in the index) is recorded by the git repo parent.

That allows the parent to record the SHA1 of those repos (but without recording from where those repos are coming from, as opposed to submodules, which keep their origin url in the .gitmodules file of the parent repo).

Check if 1507-MainApp has a .git/ sub-folder in it: that would make is a nested repo.

If you really want to consider the content of that folder as part of your repo (and discard its history), simply do a:

# no trailing slash: you need to remove the gitlink first
git rm --cached 1507-MainApp

rm -Rf 1507-MainApp/.git
git add 1507-MainApp

Then commit and push.

If you want to keep the history of those subfolder, then you would need to add them as submodule.



回答2:

It looks like your folders are submodules.

This is why they are not added.

:-)

as you can see a submodule has its own commit id since its a standalone project which is just "stored" inside root folder as the parent folder.