In my computer I have a folder nextdoor
, and there is subfolder inside it source
. All my images and code are present inside the source
folder, but somehow I am not able to push this particular subfolder to remote repository.
Remote Repository : LINK
If you go to remote repo, you can see the source
folder is not added. The subfolder is also not empty. I have tried bunch of methods but unfortunately, I am not able to push this particular subfolder up.
If I do git status
git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Total subfolders:
bin include lib local pip-selfcheck.json README.md source static_cdn
Since I am able to push all folders but why source
is not going up?
Inside source
folder:
crytography manage.py registration.txt templates
db.sqlite3 nextdoor static
.gitignore file:
# global gitignore for IDE, etc
# -- should still exclude project specific ignores in .gitignore
# system junk
.netrwhist
.Trash-1000
*.pyc
npm-debug.log
# IDEs
.idea
.env
# private files
id_rsa
*.key
Could anyone help me please?
Your last commit(815bb7d) is broken. It adds "half a submodule".
When adding a submodule using git submodule add
two things happen: a file .gitmodules
is created, containing the URL of your submodule and a "folder" is created, annotated with the commit of your submodule.
In your case you managed to create a commit containing the second, but not the first:
$ git ls-tree 815bb7d28719ab66e765ba8e265eb317766b68db
100644 blob 506c8957ac440449d375416f45c6753a3cb65d83 .gitignore
100644 blob 5f8188352aa817edb6808536f598d3ac74d448d7 README.md
040000 tree c336cc94ab9a686360ee9e6f330558cdee571e9d bin
040000 tree 334b6ff5f7c516042b7a185ec6106208df8495a7 include
040000 tree e65f051d2d0e9f2648a6b83f0ef0836893423ee5 lib
040000 tree 63a79abf5f366fc25b0b47fc527ea237163a0505 local
100644 blob 2dbf660a900d007e70510ff0ccc2c553b32d6120 pip-selfcheck.json
160000 commit 4732e130e321cacd355f8bffbf1c1726e94576c6 source
040000 tree 12edc4bcf6f3ab7a76dc5bda57a940c0caeae7e0 static_cdn
You see, the commit object is stored but the corresponding .gitmodules
file is not.
You have at least two options either throw away the broken commit ( git reset --hard 815bb7d28719ab66e765ba8e265eb317766b68db^
) or throw away you whole history altogether by deleting the .git
directory as suggested in comments.
Be aware that it is not possible to push directories ever. You always do local commits in your local repository and then sync your local repository with a remote repository by pushing your local commit.
In your case you were not able to add the files in "source" to your repository, because "source" was considered as a separate repository, a submodule.
This is the fastest, but surely not the best solution. Something seems to be broken in your git repository. The fastest way I got this to work was to destroy your git repository and start again. warning you will lose your history:
rm -rf .git
git init
git add ...
I would be better to investiage why the git repository is broken; as suggested by @michas
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.