How Do I Add Files and Folders Into Github Repos

GitHub is a web-based platform that allows you to host and manage your Git repositories.

With GitHub, you can store your code, track changes, and collaborate with other developers.

In this tutorial, we will explore the steps to add files and folders to your GitHub repository.

Whether you are a beginner or an experienced developer, you will find this guide useful in your coding journey.


Create a GitHub Repository

To add files and folders to a GitHub repository, you first need to have a repository.

If you don’t have a repository, follow these steps to create one:

  • Log in to your GitHub account.
  • Click on the “+” sign in the top-right corner and select “New repository.”
  • Give your repository a name, and provide a brief description of the project.
  • Select “Private” or “Public” based on your preference.
  • Click the “Create repository” button.

Clone the Repository

The next step is to clone the repository to your local machine.

Cloning means downloading a copy of the repository to your computer so that you can make changes to it.

To clone the repository, follow these steps:

  • Open the terminal or Git Bash on your computer.
  • Navigate to the location where you want to store the repository.
  • Run the following command:
$ git clone https://github.com/[username]/[repository-name].git

Replace [username] with your GitHub username, and [repository-name] with the name of the repository you just created.

Add Files and Folders

Once you have cloned the repository, you can add files and folders to it.

You can add files and folders using a file explorer or using the terminal.

To add files and folders using a file explorer

  • Open the repository folder on your local machine.
  • Create a new file or folder and save it in the repository folder.
  • Open the terminal or Git Bash in the repository folder.

To add files and folders using the terminal

  • Open the terminal or Git Bash in the repository folder.
  • Run the following command to create a new file:
$ touch [file-name].txt

Replace [file-name] with the name of the file you want to create.

  • Run the following command to create a new folder:
$ mkdir [folder-name]

Replace [folder-name] with the name of the folder you want to create.

Commit the Changes

Once you have added the files and folders, you need to commit the changes.

Committing means creating a new version of the repository with the changes you just made.

To commit the changes, follow these steps:

  • Run the following command to stage the changes:
$ git add .
  • Run the following command to commit the changes:
$ git commit -m "Add new files and folders"

Replace “Add new files and folders” with a brief message describing the changes you made.

Push the Changes

The final step is to push the changes to the GitHub repository.

Pushing means uploading the changes to the repository on GitHub.

To push the changes, run the following command:

$ git push origin master

And that’s it! You have successfully added files and folders to your GitHub repository.

You can now log in to your GitHub account, navigate to your repository, and verify that the changes you made are reflected in the repository.


Conclusion

GitHub is a powerful tool for hosting and managing your code.

Adding files and folders to a GitHub repository is a simple process that can be done using a file explorer or the terminal.

With the steps outlined in this tutorial, you can easily add files and folders to your repository and collaborate with other developers on your project.

I hope this tutorial has been helpful in your coding journey.

If you have any questions or comments, please feel free to share them in the comments section below.