The process is rather simple, I have jotted down all the steps in the bullets below:
- Click on “New”.
- Enter the name for your repository. Select whether you wish to keep it private (only you can see it), or make it public (visible to everyone). Then click on “Create Repository”.
- A new page will open. From that, copy the below line (it will be different for each repo), you’ll need it later:
- In your terminal/command prompt, navigate to your project directory:
git init; it will initialize a local repository in that folder.
git add .; it will add all the files in that folder to the local repository.
git commit -m "<Enter a short text to describe your commit>"
- All the files in your project are now committed to your local repository.
- Now, you need to sync your local repository (that is on your PC/system) with the remote repository (that is hosted on GitHub). To do that, first paste the command you copied earlier which specifies the URL of the remote repository, it will link your local repo with the remote repo:
git push -u origin main; this will push/sync the changes/code from the local repository to the remote repository on GitHub.
- Note: If you have large files (over 100MB), they will fail to upload and show an error similar to the one in the below image. If that is the case, please go through How to Upload Large Files to GitHub | Git LFS.
- Go to GitHub and refresh the page that you were on. You should now be able to see all the files in your GitHub repository.
- That’s it!