Inside a main repo, there is another repo (which might have been downloaded from github, i.e.), I call this a sub-repo.
I don't want to use git submodules feature.
The sub-repo might be commited and pushed to his own remote eventually. But I would like to carry on work in the main repo, ignoring that folder (sub-repo) actually is a git repo. But I would like to track the sub-repo content from the main-repo (I was studying the consequences here).
I was successful in this endeavor until the point where I pushed main-repo commits, when I noticed the sub-repo content wasn't pushed together. Even though I added it when committing.
git ls-tree --full-tree -r HEAD
I tried and files in sub-repo can be pushed together with main-repo. The following steps can be refered:
git clone <URL for sub-repo>to clone the sub-repo under main-repo
git status, you will find a untracked folder sub-repo, then use
git add sub-repo/and
git committo track
git add sub-repo/new.txtand
git commit(note: it’s run in the
git pushto push to remote main-repo, and you can find the file new.txt also there. Also you can use
git ls-filesto find the file
Note: You may have noticed that the mode is 160000 if we use
git add sub-repo and
git commit, and mode 100644 if we use
git add sub-repo/ and
git commit. 1600000 is Gitlink, it means you record a commit as a directory rather than a subdirectory or a file, somewhat like submodules. 100644 means regular non-executable file. So you can treat sub-repo as a folder.