How to Upload a Folder and Subfolder to Github
Git Tutorials
Create Folder in GitHub: A Guide
In that location is no Git feature that supports the cosmos of an empty folder. To create a folder in Git, you lot must commit a binder to a repository that contains at least one file, even if that file is subconscious.
In this guide, nosotros're going to discuss how to create a folder on GitHub. Nosotros'll walk through an case of how to create a folder from the Git control line, and give instructions on how to create a folder from the GitHub web interface.
Create a Folder in GitHub: From Git
We're going to start work on an update for a project chosen ck-git. We already have a Git repository set upwardly for this projection. Before we start working on our updated code, we're going to create the directory structure for our code.
Detect Your Bootcamp Lucifer
Career Karma matches y'all with summit tech bootcamps
Access exclusive scholarships and prep courses
By continuing you agree to our Terms of Service and Privacy Policy , and y'all consent to receive offers and opportunities from Career Karma by telephone, text bulletin, and email.
Our GitHub repository currently contains no folders:
We want to create a binder called docs
and a binder called dev
. To do this, nosotros're going to utilize the mkdir command:
mkdir docs dev
This command creates our ii directories. If we add together these folders to a commit and push our changes, they volition not prove up on GitHub. This is because GitHub does not display empty folders.
"Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!"
Venus, Software Engineer at Rockbot
To create our new folders, we need to add contents to our folders. Considering we are simply initializing our project, we can add in a few blank unmarried files.
These blank files will let us create our folder without having to actually start work on our updates before nosotros take created the directory construction and uploaded information technology to Git.
Let's create 2 bare files to populate our new folders:
touch docs/.gitkeep touch dev/.gitkeep
We accept created two files called .gitkeep
. Our 2 new directories now incorporate i file each. The .gitkeep
file name is often used to create blank folders. However, at that place is no requirement that the name of your file needs to be .gitkeep
to create a folder.
Now that these files exist, we tin track our otherwise empty folders and commit our code:
git add together * git commit -m "feat: Create directory structure" git push
The git add together control adds our files to the staging area. The git commit command creates a commit with our changes. The git button command pushes our changes to our remote repository. Our remote is hosted on GitHub.
Let'due south see what happens when we run these commands:
[master f10ed95] feat: Create directory construction 2 files inverse, 0 insertions(+), 0 deletions(-) create mode 100644 dev/app.py create mode 100644 docs/Start_Here.md ...
Our code successfully changes our files. We now have ii new folders in our GitHub project: dev and docs. We can cheque that our folders exist by navigating to the GitHub dashboard for our project:
Each of these folders contains one file. Now that we've defined the directory structure, we are costless to proceed working on our project.
It's non e'er necessary to upload empty folders earlier you accept worked on them. If you need to for some reason, such every bit if you are required to evidence your new structure to other collaborators, these are the steps you should follow if yous desire to add the folders from Git.
Create a Binder in GitHub: From the Web Dashboard
There is no user interface characteristic to create a blank folder in GitHub. To create a new folder, you lot demand to create a new file and specify the directory in which that file should announced.
In other words, yous can merely create a folder later on you lot have created a file.
Nosotros want to add one more directory to our lawmaking called "assets". To start, allow'due south navigate to our repository and click on the "New file" button.
In the top text field, nosotros're going to create a file called "assets/.gitkeep":
This will let us create a binder called avails
and a file called .gitkeep
in that folder. Git automatically displays the new folder path when you type in a /
.
Optionally, you can add text or code to the file that yous accept created. Once more, ".gitkeep" is just a placeholder file name. You can name your file whatever you lot want.
Adjacent, click Commit new file
. This volition add our new file to our repository. If we get back to our main folder, nosotros tin see that our new folder and file have been created:
We've now successfully created a folder in GitHub.
Decision
GitHub does not let you to add blank folders to your Git repository. A folder must contain a file before you can add it to a repository. If you want to create a new folder, create it first then add a placeholder file into that folder. Then, add together the new folder and file to your Git repo.
Now you take the tools you need to create a folder in GitHub like a pro!
Nearly u.s.: Career Karma is a platform designed to assist job seekers notice, research, and connect with chore training programs to advance their careers. Learn near the CK publication.
What's Adjacent?
-
Want to take action?
Get matched with meridian bootcamps
-
Desire to dive deeper?
Inquire a question to our customs
-
Want to explore tech careers?
Take our careers quiz
James Gallagher
X
Find the right bootcamp for you
Many careers in tech pay over $100,000 per year. With help from Career Karma, y'all tin can find a training program that meets your needs and will set you upwardly for a long-term, well-paid career in tech.
By continuing yous agree to our Terms of Service and Privacy Policy, and yous consent to receive offers and opportunities from Career Karma by telephone, text message, and electronic mail.
Source: https://careerkarma.com/blog/git-create-folder-in-github/
0 Response to "How to Upload a Folder and Subfolder to Github"
Post a Comment