How to upload a project on GitHub using Git

The process is rather simple, I have jotted down all the steps in the bullets below:

  • Click on “New”.
image
Create a GitHub repository
  • 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”.
image 1
Configure your repository’s settings
  • A new page will open. From that, copy the below line (it will be different for each repo), you’ll need it later:
image 2
URL for remote repository hosted on GitHub
  • In your terminal/command prompt, navigate to your project directory:
image 3
Navigate to your project directory
  • Run git init ; it will initialize a local repository in that folder.
image 4
git init
  • Run git add . ; it will add all the files in that folder to the local repository.
image 5
git add .
  • Run git commit -m "<Enter a short text to describe your commit>"
image 6
git commit -m “<commit message>”
  • 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:
image 7
git remote add <remote repo’s URL>
  • Run git push -u origin main; this will push/sync the changes/code from the local repository to the remote repository on GitHub.
image 8
git push -u origin main
image 10
Large files – use 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.
image 9
  • That’s it!