Git is a popular way to manage multiple projects. Git is also known as a version control tool. We will see how to set up git with Github on Windows/Linux/macOS. If you like you can follow official docs to setup git with Github.
To begin with, let’s know first why it is called version control. Let’s suppose you are working on a project and added this project to Github. Now suppose your project needs some update so you updated and pushed again to GitHub. But wait in the update you did something wrong. Well, there comes our point GitHub keeps your push and commits in history, so using git you can always return to the previous version of your project.
Now time to connect GitHub with our local machine. open your terminal or cmd anywhere and follow the below command.
git config --global user.name "Your name here" git config --global user.email "firstname.lastname@example.org" //email id used in github
Now you can work with git and github.
Next, you can set up SSH if you don’t want to enter username and password every time you push some code on Github.
For setting up SSH public and private keys follow the official documentation of Github here. They have explained on every specific Operating system ( Windows, Linux,macOS).
Some beginner commands you will need all time.
suppose you created a project on your local machine and now you want to push it to your GitHub account. To do that following are the steps first time you will use.
Go to your github account and create a repository.
Next screen will popup with successful repository created and you will see few commands to get started.
If you have not setup SSH then choose HTTPS like above highlighted. And as of now we are uploading our created project so we will choose push an existing repository.
Next , On your terminal (make sure you are in project directoey ) type the following command to init a git repository in your project.
git remote add origin your_repo_url
your_repo_url will be in the above screen I have highlighted.
git add .
do not forgot
. , it is important as it says add all files.
git commit -m "your message about this push"
git push -u origin master
Thats it . Now you go to github and refresh you would see your code there.
So that was all about how to set up git with Github on Windows/Linux/macOS and some basic commands. If you have query leave in the comment box.