Home > Back-end >  I have these three files under a github repository. Is there a way I can put these files in a folder
I have these three files under a github repository. Is there a way I can put these files in a folder

Time:05-02

enter image description here

I would like it as to where if you were to click on the folder, these files show up.

CodePudding user response:

You can clone the repository. Then create a subdirectory and give it an appropriate name. And then move these files to this directory. And then stage the changes and commit it. And this would get to the desired result.

Note the subdirectory should be created under a directory such that it is a git repo.

CodePudding user response:

Use / in the file name field to create folder(s), e.g. typing folder1/file1 in the file name field will create a folder folder1 and a file file1.

You cannot create an empty folder and then add files to that folder, but rather creation of a folder must happen together with adding of at least a single file. This is because git doesn't track empty folders.

On GitHub you can do it this way:

  • Go to the folder inside which you want to create another folder
  • Click on New file
  • On the text field for the file name, first write the folder name you want to create
  • Then type /. This creates a folder
  • You can add more folders similarly
  • Finally, give the new file a name (for example, .gitkeep which is conventionally used to make Git track otherwise empty folders; it is not a Git feature though)
  • Finally, click Commit new file.
  • Related