Henry
Henry

Reputation: 173

Cannot add a folder to github using git

I tried to add a new folder to my github using "git add *", "git commit -m "something", and then "git push".

This is a screenshot of my GitHub repo, where I have added "angular2-webpack-starter", but it is not even a folder.

https://i.sstatic.net/QdOxP.png

I tried to do commands above again, and it shows

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

What does that file (angular2-webpack-starter) icon mean?
How can I add that folder to my GitHub repository?

Upvotes: 1

Views: 1501

Answers (1)

VonC
VonC

Reputation: 1323223

That icon means: nested git repository.

Meaning: when you did a git add *, you added the top folder of a nested git repo angular2-webpack-starter, recording it as a gitlink (a special entry in the parent repo, as a SHA1 representing the nested repo tree)

If you really want to include the content of angular2-webpack-starter, you need to deleted in ``angular2-webpack-starter/.git` subfolder, and remove the gitlink, before adding the folder back in:

git rm --cached angular2-webpack-starter  # no trailing slash
git add .
git commit -m "record deletion of angular2-webpack-starter gitlink"

rm -Rf angular2-webpack-starter/.git
git add .
git commit -m "record deletion of angular2-webpack-starter"

git push

But a cleaner solution would be to add that same angular2-webpack-starter as a submodule, which would make it as a gray folder (again), but this time with a .gitmodules recording from where said angular2-webpack-starter is coming from.

Upvotes: 7

Related Questions