Home > Back-end >  Pushing index.html file to GitHub using git
Pushing index.html file to GitHub using git

Time:11-16

When I push my index.html file to GitHub using git do the additional folders I created for that particular project get pushed too, folders like images and pages or do I have to manually push them, even though on git it said they've been committed it doesn't show on my GitHub all I see is the README.md and index.html files and none other

I thought when I pushed the index.html file to GitHub it'll all get pushed.
But when I tried opening the code using GitHub the pages linked to it couldn't be found on the server

CodePudding user response:

There are two possibilities: either the directories are empty, or they are non-empty.

  • Are the directories empty? If so, then the answer is:

    git is only concerned with files; if a certain file is in a directory, it will automatically create the directory. If a directory is empty, it never gets committed. If a directory becomes empty, then it automatically disappears from the repository.

    When people need a specific directory to exist in the repository, they sometimes place a dummy file in it, just in order to coerce git to keep that directory in existence.

  • Are the directories non-empty? If so, then the answer is:

    You only committed "index.html", so you should not expect anything but "index.html" to be committed.

CodePudding user response:

To push all files to git run following commands:

git add .
git commit -m "commit message" 
git push
  • Related