Github, Knowledge and Skills

How to create a github repository from uploading a local folder

To create a GitHub repository by uploading a local folder, you can follow these steps:

  • Sign in to your GitHub account. If you don’t have one, you can create a new account at https://github.com/join.
  • Once signed in, click on the “+” icon in the top-right corner of the GitHub page and select “New repository” from the dropdown menu.
  • On the new repository page, provide a name for your repository and optionally, a description.
  • Choose whether you want your repository to be public (visible to everyone) or private (only visible to you or people you grant access to).
  • Optionally, select the checkbox “Initialize this repository with a README” if you want to create a new README file in your repository.
  • Click on the “Create repository” button to create the repository.
  • After creating the repository, you’ll see a screen with instructions on how to push an existing repository from the command line. However, since you want to upload a local folder, you can skip those instructions and continue with the next steps.
  • Open a terminal or command prompt on your local machine and navigate to the folder you want to upload to GitHub.
  • Initialize a new Git repository in the folder by running the following command:
git init
  • Add the files in the folder to the Git repository by running:
git add .
  • Commit the files to the repository with a commit message by running:
git commit -m "Initial commit"
  • Go back to the GitHub repository page and copy the repository’s remote URL. You can find it under the “Quick setup” section or by clicking on the green “Code” button and copying the URL.
  • In your terminal or command prompt, add the remote repository URL by running the following command:
git remote add origin <remote_URL> 

Replace <remote_URL> with the URL you copied in the previous step.

  • Finally, push the local repository to the remote repository on GitHub by running:
git push -u origin master 
  • This command will push the “master” branch to the remote repository. If you have a different main branch name, replace “master” with the appropriate branch name.
  • Once the push is complete, refresh the GitHub repository page, and you should see your local folder’s contents uploaded to your GitHub repository.

That’s it! You have successfully created a GitHub repository by uploading a local folder.

Leave a Reply

Your email address will not be published. Required fields are marked *