Almost everyone has heard of Git and Github. Some have gone even further and used “ git clone https://github.com/abcd/xyz.git
“ but haven’t used git other than this. So today, we will show why you need to use git.
Git is the most widely used distributed version control system (DVCS/VCS). Version Control System is a software that
keeps track of the source code development.
So you would ask why do you need a VCS. Here’s why:
Many of us have worked on different projects
that involved writing codes and this is how we generally developed our
software:
One person writes a code. Mails it to his/her team members.
Development begins.
Changes are made and there comes a point where the new changes don’t work and
the changes were done in the working code. *Cursing the person who made the
recent changes*
If fortunately you had made backups of your working code, your code folder
would look like this. *Satan laughing*
There comes a point where everyone in the
team has his/her own modification to the existing base code. Bringing their
code together becomes a nightmare. *Everyone is fighting on who will do it*
And many more problems that we face….
Solution to all these problems is using Version Control System. Here comes git,
one of the many version control system out there.
1.) Keeps track of the changes made (What, When and by whom)
2.) Can easily revert to any point in history (Last week code or last month
code. Yes !!!!!!)
3.) Ability to merge code by different contributors without any conflicts.
(Yayyy !)
4.) No cluttered mess of files like shown above. Just one code file and a
hidden .git folder where all the magic happens J
And many more magic elements………….
So how do we use this magic wand???
Firstly, Install git in your laptop:
Git for Windows ( https://git-for-windows.github.io/
)
Git for Linux ( https://git-scm.com/download/linux
)
Git for Mac (https://git-scm.com/download/mac
)
Now all you have to do is ‘init’ialize. ( don't worry if you didnt get the pun ;P )
Go the folder where you want to keep track of the changes made and type the
command in the terminal.
git init
This will magically create a .git folder in your current directory
Now you have to tell git which files it
should keep track of so type the command
git add File_name_to_be_tracked
After editing the code and reaching a milestone. Make it your checkpoint where
you can return to in future.
git commit –m “Message for your convenience ”
Always write a short and descriptive message when you are committing. Always.
And thus you have your own Git repository !
However these commands will just get you started. There’s a lot more in git
than this.
Follow this tutorial link to get you familiar with git: https://try.github.io/
Note:
Many of you are confused between git and github and use these words
interchangeably but they are not same.
Git in a Version Control System as explained above.
Github is a web-based service that hosts Git projects .
So that’s all for this post. Hope you start using Git from now onward.
Happy Committing ! J
- Sachin Parekh.