Before knowing about Github, we need to understand what is git.
Git is an open source version control system that allows you to easily record different versions of your project as you develop your project and also allows you to go back to a stable/consistent version of the project if you screw things up.
You can check out my post on "Git Tutorial for Beginners" to understand the basic commands and workflow with git if you don't know about it.
Github is a website that provides hosting service for your projects. The main feature of github is that it allows version control for your project using Git.
So Github is a place where you can store your projects privately or publicly and keep track of all the changes made so that you can go back to a stable/consistent version of the project if required. Github also allows you to collaborate with other developers on different projects.
+icon in the top navigation and click new repository in the dropdown menu
This will create an empty git repository on github
Now the only thing you need is to connect your local repository with your github repository.
git cd /path/to/project/github_tutorial
git remote command will create a link between your local and github repository.
git remote add origin https://github.com/username/git_tutorial.git
Put your github username in place of username and your github repository name in place of git_tutorial
Now we will push all the changes made in the local repository to the github repository with the following command:
git push -u origin master
When executing git push, Gihub will ask for your username and password
That's it! Now we can make changes locally in our project and when we are ready, we commit the changes and push the code on github. So the workflow looks something like this:
# make changes/updates/new feature git add . git commit -m "commit message" git push
When you or someone else make changes on your github repository then you can pull the latest changes with:
This will make your local repository upto date with all the latest changes made in the github repository
From this post we learned to:
I hope you have learned something out of this post.