git commit directory

2020-08-23 04:22发布

问题:

I created a repo and, locally, dragged-and-dropped an existing project directory into the repo. I then did something like git add directory/ and committed it and pushed it. When I look at my repo on github though, all i see is the directory with no subfolders, no content. How do I push all of the files and subfolders of that project to the repo?

回答1:

If the files are in your local commit, then they should be displayed on Github.

Load up gitk (just type gitk from your Git bash command prompt); and check to see whether all the files below the folder were actually added in the commit you pushed to Github.

If they weren't, and a git add . doesn't seem to be working, check that your .gitignore isn't excluding them for some reason.



回答2:

Try this:

$ git add directory/*

(or *.h, *.c, and so on).

and then check as Aaronontheweb suggests (with gitk or git status) that the files are included in the staging area. Not only the folder name.



回答3:

Try git add . from the base project folder - this should recursively add all files to the repo.



回答4:

Try :
$ git add directory1 directory2 director3
This will add the above directories along with all the files present in respective directory.
You can conform by :
$ git status
This should show all the files that will be present in next commit.



标签: git github