Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Git is the most commonly used for version control. Git help us to makes collaboration easy. Even we work by our self, we will love it.
Git runs in our local machine. We also can use online host such as Github, Gitlab, and Bitbucket.
We can easily download git from this Download page.
For MacOs, I prefer to use homebrew instead. Just simply type this command
brew install git.
And in linux, I will do
apt-get install git.
git in our terminal to check if it's successfully installed.
There are two ways if we want to communicate with github.
First one is using HTTP, and the second one is using SSH. Actually we don't need anything else if we want to clone a github repository using HTTP, but we will need some configurations if we want to use SSH.
This example is explaining in linux machine, need a little adjustment if we run MacOs or Windows.
- Generating a new SSH key
Run this terminal command to create a new SSH key
$ ssh-keygen -t rsa -b 4096 -C "email@example.com"
By default, the key will saved in this path
- Adding the SSH key to our github account
id_rsa.pub file generated by previous command.
Go to our github account. Find Settings - SSH and GPGP keys - New SSH key.
Create a Title and paste our Key there, then hit Add SSH Key.
We can run this command to test if our key is successfully configured.
$ ssh -T firstname.lastname@example.org Hi zakiarsyad! You've successfully authenticated, but GitHub does not provide shell access.
# setting our username $ git config --global user.name "zakiarsyad" # confirm that we set userneame correctly $ git config --global user.name zakiarsyad
# setting our username $ git config --global user.email "email@example.com" # confirm that we set userneame correctly $ git config --global user.email firstname.lastname@example.org
git is ready to use in our local machine.