GitHub is a great tool to be used when programming, as it helps store your code over the internet. It makes your project more organized, easier to develop, and allows you to collaborate with friends or other developers. In addition, GitHub works smashingly with Visual Studio Code.
If you’re still not recognizing a need for GitHub, do not worry – you will soon.
In this short tutorial, I’m going to show you how to connect your project with GitHub from the command line.
First, navigate to your project in your computer’s terminal and run:
That will initialize your project with Git. Next, run:
git add .
That command will add all of your files to the git repository that we initialized in step 1. After, run:
git commit -m "Initial Commit"
This commits all your files to your repository. Next, we need to set up a GitHub repository. To do this, go to (github.com)[github.com] and either sign in or create an account. After that, create a new repository by clicking the “new” button on the sidebar on the left side of the screen.
Next, give your repository a name, select if you want it to be public or private, and then click create at the bottom of the screen.
Now, copy the repository link from the top of the page.
Then, go back to your terminal. After, run the following command:
git branch -M master
This creates a master branch for your repository. Finally, run:
git remote origin add <repository link>
Make sure to replace
<repository link> with your GitHub repository link from above. The last thing we to do is to push all our files to GitHub! Do that with the following snippet:
git push -u origin main
Congrats! Now we’ve pushed our project to GitHub, and you should be able to see it if you reload your GitHub repository’s page.
However, let’s say you continue to edit your code. How can we update your GitHub repository? It can be updated with this series of commands:
git add . git commit -m "Your Commit Message Here" git push -u origin main
If you're interested make sure to follow me or check out my Github profile!