Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)
I want to create a folder in the github repository and add files in that folder. How to achieve this?

3 Answers

+1 vote
by (62.9k points)

You cannot create an empty folder and then add files to that folder, but instead, the creation of a folder must happen together with the addition of at least a single file. On Github you can do it this way:

  • go to the folder within which you would like to make 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, (eg. .gitkeep which is conventionally used to allow git to track otherwise empty folders; not a git feature though)

  • finally, click Commit new file.

create folder in github-How to create folder in github repository?
Intellipaat-community
by
Hi,
Thanks for the post. It works. can I go further and make the new folder private? Just the folder, not the whole repo
0 votes
by (37.3k points)

So, firstly, we can’t create an empty folder on github. So we have to create a file inside the folder while creating the folder on github.

There are a few steps that we must follow while creating a folder on github:

  1. Click on the add button inside the repository on github and then click on create a file

  2. A new interface will be opened up and over there, enter the name of folder in the box of “ name of your file “ and make sure that after writing name of folder, you specify a ‘/’ , and after that, write the name of the file. For eg.: If the folder name is FAQS and file name is “questions” then write it as “FAQ/” and after that write the name of the file, which is “questions” .

  3. Then click on the button commit changes. And a new dialog box opens up and then again click on commit changes.

  4. After this, you will notice that the folder and a file in that folder have been created.

After following all these steps, the creation of folder will be done.

0 votes
by (1.8k points)

To determine the fork that you have cloned at the very beginning, you may want to verify the address of the remote repository that is linked to your local git repo. This is done in several steps: 

To create a new directory and add files to it in Github, obey the following rules: 

  • Go to Your Repository: Use a web browser and navigate to your GitHub Repository. 
  • Create a File in a Given Directory: On the repository page, click on Add file > Create new file. 
  • When you want to create a folder, type the name of the folder followed by a / in the filename box. If you wish to create a folder called my_folder, for instance, you can type my_folder/filename where “filename” is the name of a file to be created (say, README.md). The / symbol will be treated as the folder separator and hence the folder will be created by GitHub if it does exist.

Add and Save Content: 

  • Provide some content for the file, scroll down, write a commit message, and click on the option Commit directly to the main branch (or choose to create a new branch if you want to). 
  • Press Commit new file. Add More Files to the Folder: To add other files to the folder, follow the above steps again but specify the name of the existing folder plus the / and the new file.

Related questions

+4 votes
3 answers

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...