Git is the world’s most popular version control system, it helps us manage our project files.
These words do not mean anything, let's talk about the history of Git first.
our story starts in the year 1991 with the creation of the Linux Kernel which is an open-source project created by Linus Torvalds and throughout the 90s developers would make changes to the Linux code and the patch is passed around as archive files. Which as you know is a very tedious task. In 2002, Linux Kernel started used a proprietary DVCS or Distributed Version Control System called BitKeeper but in 2005 BitKeeper revoked its “Free of Charge” status which pissed off the Linux community so they started working on their own Version Control System called Git which has all the features of BitKeeper but it is completely open-source and free.
Well even I don’t know what it actually meant, I thought it was actually G I T and those alphabets are some meaningful words like Global Information Tracker or something. Then I did some research and found something really funny about Linus’s personality, the creator of Git. He has a tendency to name things after himself as you know from his Operating System Kernel Linux. According to Linus, Git is actually a slang used in Britain for someone who is a completely ignorant, dumb and annoying person so he chose this name for the SCM he made. SCM is Source Code Management which is another way of saying Version Control.
What does GIT do?
1. History: Git makes a track of every file you ever changed in your project.
For Example, You are working on a website and you made some changes in the CSS file and a month from now, your code broke down and the UI looks completely bad. Now you have 2 options here, 1. Find the bug and fix it or 2. Use git and when something like this happens, just revert back to the code that you coded a month ago.
2. Collaboration: Git makes it easier to collaborate with your team
This is one of the major reasons for the creation of BitKeeper and then Git, developers around the world can contribute to your project with your permission of course without any issues. If you don’t use Git in your project then everything will work well if there is only you working on it. But as soon as your team size increases a situation similar to this will happen. Imagine you are working on a script for a Youtube video and you wrote the first section and told your team member to validate that section and make some changes if necessary. And you send that person the script file. Now you are basically frozen and will not be able to work until your teammate sends the updated file. If you are using Git or any other Version Control, you can make changes to the file while the other person is working on that project without the fear of accidentally overwriting their work.
3. Feature Branching: : Consider that you need to add a feature to your application and you are not sure if that will work or not. So instead of creating a new copy of the project you can just create a new branch and code the new feature there. And when you test out the feature, you can Merge that feature branch to the main branch.
How to install Git?
Windows
If you're using Windows, then simply go to this site and download the exe file. I recommend you to keep all the default settings while installation.
Once Git is successfully installed in your system, follow these steps.
- Click window-key + R, and type "cmd" in the popup box at the bottom left corner and click enter. This should open the command prompt.
- Next, write the following.
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Make sure you enter your name and email id respectively.
So that pretty much is the process for installing Git on Windows.
Mac OS
There is a very high chance that you have git already installed in your system. To if you have git installed open Terminal, then write this command and press enter.
git --version
If you see something like git version` followed by some number, then you have git installed. But it's most likely outdated even if you got a brand new mac.
If you have git already installed, then first write the following command.
sudo mv /usr/bin/git /usr/bin/git-apple
This command will in a way, "remove" your old git. Next, you have to install Homebrew using this command.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This should take some time but when it's over, write this command.
brew update && brew upgrade
This will take some more time, next finally, you can install git. Just write
brew install git
After git is installed, write this command.
brew link --force git
and then once more write:
git --version
and see if everything is working properly. Then you can follow point 2 from the Windows installation guide above.
Linux
Installing Git in Linux is pretty straight forward and if you're using an Arch Linux based distro them most likely your git is up-to-date. But in this post, I'll walk through the installation process for Ubuntu because that's what most beginners tend to use.
sudo apt-get update
sudo apt-get install git
and that's it, now you can follow point 2 from the Windows installation guide above.
That is the end of Introduction to Git (part 1)