1

I was trying to push multiple folders containing sub folders and documents to a repository i made on GitHub. I did the following:

  • I went into the folder which had 8 Sub folders and a readme.md in it, with again different sub folders and documents.

  • I initialized the folder using git init.

  • then i added every single folder to the git one by one(in staging area) using git add folder_name.
  • And the last file I added was the readme.md then i made commit to the readme file using git commit -m "Initialize readme.md".
  • Then I pushed this to my GitHub repository, using git push origin master.
  • I got all my folders on GitHub in my repository, but only readme and last two folders were showing properly, which had sub folders in it with some documents, remaining folders which did not had any sub folders but only documents were shown in grey color folder which gave no response on clicking.
  • I have deleted all those folder in grey color.

But I want to know how i can send over folder with different sub folders on GitHub repository using git push properly?


One more question:

  • How can i add images with different format or PDF documents to my GitHub repository?
Prateek
  • 185
  • 1
  • 3
  • 12
  • Possible duplicate of [GitHub does not let me access Subfolders](http://stackoverflow.com/questions/19917136/github-does-not-let-me-access-subfolders) – Tim Feb 03 '16 at 08:31
  • *How can i add images with different format or PDF documents to my GitHub repository?* simply add & commit like any other file. But please 1 question per question – Tim Feb 03 '16 at 08:32
  • Also http://stackoverflow.com/a/25580163/6309, http://stackoverflow.com/a/30275888/6309, or http://stackoverflow.com/a/34611908/6309 – VonC Feb 03 '16 at 10:08
  • @TimCastelijns Yeah I should not ask more than one question in a post, will keep that in mind, and Thanks for the link, I am trying to understand it, i am very new to git, but trying my best. – Prateek Feb 03 '16 at 15:59

1 Answers1

0

You can't add empty directories, you need to fill it with a placeholder file. See Git FAQ

Currently the design of the Git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.

Directories are added automatically when adding files inside them. That is, directories never have to be added to the repository, and are not tracked on their own.

You can say git add <dir> and it will add the files in there.

If you really need a directory to exist in checkouts you should create a file in it. .gitignore works well for this purpose (there is also a tool MarkEmptyDirs using the .NET framework which allows you to automate this task); you can leave it empty or fill in the names of files you do not expect to show up in the directory.

If you add non-text files, you might want to specify it as binary in .gitattributes so that git will never try to modify (and hence corrupting) it.

Eg.

*.png binary
*.pdf binary
Community
  • 1
  • 1
Roy Wang
  • 11,112
  • 2
  • 21
  • 42