This lesson deals with pushing your coding work to GitHub.
What is Git?
Atlassian has a good definition for it:
Git is a mature, actively maintained open source revision control system used by thousands of developers around the world.open-source
What is GitHub?
GitHub is an online version of Git that allows you to not only store your code but also track all the changes you have made to it. Multiple people or teams can work across the code, and everyone can see what’s going on.
It’s a Microsoft company, and you can check it out and start an account for free here: github.com
Let’s start!
I am using VS Code to do my coding work. So, I am using its built-in Terminal to push my changes to Github.
Step 1: Initialise a Git in your local machine terminal
git init
Step 2: Check if it has been initialized
git status
Step 3: Add your files to this new Git and check the status again
git add .
git status
Step 3: Commit your changes
git commit -m "Initial Commit"
The “initial commit” is a general comment. You can add what you like here but make it understandable for all.
Step 4: Go to GitHub (website) and create a new repository there.
Step 5: Copy the SSH URL
GitHub gives you all the instructions on the next screen that you need to complete after creating your repository. I will cover them below as well. The first step here is to copy the SSH link.
Step 6: Come back to your VS Code Terminal and insert the copied SSH URL like below:
git remote add origin git@github.com:emanoj1/python-crash-course.git
Remember: This is my file 🙂 Replace the URL after “origin” with your own!
Step 7: Create a Main branch on GitHub
git branch -M main
Step 8: Push the changes from your local repository to GitHub’s repository.
git push -u origin main
Step 9: Go over to GitHub website repository and you will now see your files there!
Step 10. For all future updates or commits, just do the following:
git add .
git commit -m "your comment"
git push
That’s it. I hope this has helped!
Leave a Reply