Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to commit a directory into a git repository?

Tags:

I read the great git tutorial here, I'm unable to create directories.

My folder structure is:

Code - Python - C++ - F# - ...

From within a initialised local repository "Code" I changed into the subfolders "Python", "C++", ... did git init and now I want the same structure on my versioning server.

% git commit -m "added directories" # On branch master nothing to commit (working directory clean) 

I guess I got something completely wrong, did I?

Thanks, wishi

like image 618
wishi Avatar asked Oct 15 '09 17:10

wishi


People also ask

How do I commit a directory in git?

Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed. Enter git commit -m '<commit_message>' at the command line to commit new files/changes to the local repository.


1 Answers

Try to add some files to directories first. You can add some dummy file to directory, and remove that file when you have added the actual content for the directory.

Git does not track empty directories, it tracks files and their contents.

git init mkdir foo touch foo/dummy_empty_file  git add foo git add foo/dummy_empty_file git commit -m "adding files" 
like image 186
Juha Syrjälä Avatar answered Oct 06 '22 05:10

Juha Syrjälä