Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploading a empty folder to github [duplicate]

Tags:

git

github

Possible Duplicate:
How do I add an empty directory to a git repository

I want to upload a empty folder to my github repo, I created the folder but...

mkdir foldername
touch foldername
git add foldername
git commit -m 'Added foldername'
git push origin master

...always gives me the following error:

# On branch master
nothing to commit (working directory clean)
like image 299
boutouve Avatar asked Jan 19 '23 04:01

boutouve


2 Answers

Have you tried following github's instructions?

mkdir foldername

cd foldername
git init
touch README
git add README

git commit -m 'first commit'
git remote add origin [email protected]:your_user/foldername.git
git push origin master

You shouldn't be touching the foldername, but instead a file inside that folder.

For example touch README. Or, even better, touch .gitignore.

Explanation

Git could track directories since a "tree" (which corresponds to a directory) has content: the list of blobs (files) and trees (sub-directories). So git actually can (in theory) record empty directories. The problem lies in the index file (the staging area): it only lists files; and commits are built from the index file.

Finding out more

If you're interested about this decision of ignoring empty directories in git you can read this thread from the git mailing list archives.

like image 112
Igor Popov Avatar answered Jan 27 '23 06:01

Igor Popov


Git cannot track empty directories by design (an empty directory has no content, while git tries to track content). You can add a placeholder file (an empty file ought to be enough) if you want to add the directory, or live with the limitation.

like image 37
Egon Avatar answered Jan 27 '23 07:01

Egon