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”.
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”.
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:
URL for remote repository hosted on GitHub
  • In your terminal/command prompt, navigate to your project directory:
Navigate to your project directory
  • Run git init ; it will initialize a local repository in that folder.
git init
  • Run git add . ; it will add all the files in that folder to the local repository.
git add .
  • Run git commit -m "<Enter a short text to describe your commit>"
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:
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.
git push -u origin main
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.
  • That’s it!

Leave a Reply

%d bloggers like this: