Can I upload folders along with the code in GitHub?

13

I've already put codes in my repositories in Github once, but now I'm messing around with Netbeans using HTML5, and I have other folders like CSS, Javascript, and the like. Is it possible, when uploading the code, to upload these folders too?

    
asked by anonymous 19.07.2017 / 22:21

3 answers

15

Git does not allow empty directories. But when I need to upload a folder I create a hidden file inside the directory to upload this directory. For example:

touch pasta/.teste

Apply git add pasta/ to add a specific folder or git add . to upload all folders and changes.

    
19.07.2017 / 22:23
12

As long as these folders are not listed in the .gitignore file and are not empty they will be sent to the repository.

Do not forget to add the folders before commitar

$ git add pasta/

If you want to send a folder that does not have commit files, you'll need to use some alternate method for this. One approach I use a lot is to create an empty file with the name .getkeep . That way I can tell you what the file's utility looks like just by looking at your name.

You can create this file using the command touch

touch pasta/.gitkeep
    
19.07.2017 / 22:22
2

I like to do it in a way that I learned to do in projects on Laravel. When I need to have the folder in production, but I do not need the files inside those folders to be monitored, I create a .gitignore within the folder in question and I put the following excerpt:

And I put PastaQueEuQuero/.gitignore :

*
!.gitignore

In this case only the .gitgnore file along with the folder is sent to the repository when doing git add PastaQueEuQuero .

    
20.07.2017 / 21:28