Version control, it may sound fancy, but it is a simple thing. You probably have done some form of version control in some
way or another like the good ol' copying of file in another directory, saving it in a cloud storage, and storing it in a USB.
Yeah, you get the idea, it is a form of file backup but that is not what version control is all about.
As said by the *About Version Control* section on the official Git book, *Pro Git* (in which you can download it from this
[link](https://git-scm.com/book)), a version control system (VCS) is:
> a system that records changes to a file or set of files over time so that you can recall specific versions later
Well, it usually revolves around the changes happened on the files. That's how version control systems help you manage your
files. As said by probably a thousand of articles and posts about Git (and other VCS), think of version control system as some
kind of an EPIC save button that allows you to epically save things in case of an epic fail. Also, keep in mind that VCS are
not only used for managing code files but also for other files as well whether it's a text file, a document file, or a spreadsheet
so even a non-programming project (whatever that is) can utilize a VCS.
And as such tool with such usability, it is used mostly on big projects especially for those that requires multiple person (which
composes of probably 95% out of those projects). In programming world, well, it is quite used extensively everywhere unless you
are in one of those groups that hate using VCS possibly from traumatic events while using it.
This is why most of the recommended suggestions when entering the chaotic world of programming includes learning a version control
system. This is a very helpful tool to be included in your toolkit and in your career since most tech group uses VCS, particularly
Git.
Well, yes, there are [other version control softwares](https://en.wikipedia.org/wiki/List_of_version_control_software) out there,
but most of them really uses either [Subversion](https://subversion.apache.org/) or [Git](https://git-scm.com/)
(also keep in mind that they have a difference in terms of how they are being used).
If you want to have an overview on different version control systems, you can take a look in the *About Version Control* section
on *Pro Git* where they will obviously glorify the system Git uses. Also, if you have the time to do so, you can refer to
[this list of common vocabulary](https://en.wikipedia.org/wiki/Version_control#Common_vocabulary) to have a slight idea in case
I've mentioned words such as *commit*, *branch*, and other words in advance.
And speaking of Git... Yeah, now we are going to talk how to Git... (HA! You thought I am going to include 'good/gud', eh?)
## History Lesson on Git
Well, before we *really* discuss Git. Let's have a little history lesson with Git, shall we? *(Of course, it's already set and
you can do nothing about it [maybe except skipping this part but whatever])*
As you might have read on your own research with our quick reference teacher, Wikipedia-*sama*, Git was designed by Linus Torvalds
(yes, the guy that developed the Linux kernel) from his need of distributing source code in his own way ever since the
VCS that the Linux community uses ceases from becoming a free-of-charge tool.
After that incident, the Linux community (in particular, Torvalds) decided to write their own VCS that is similar to the ones they
have used, however with additional criteria that makes Git to be what it is today. Such criteria that they wanted to be for Git
are:
- simple
- easy to use
- fully distributed
- highly performant
- difficult to lose data
And within 2005, Git was born. Two months after Torvalds created the thing, he passed the maintenance duty to
[somebody else](https://en.wikipedia.org/wiki/Junio_Hamano) and became a major contributor to the project, seeing as he is the
one who managed to get Git to be in its version 1.0, then maintained the project many months after.
Then in 2008, GitHub (and the [octocat](https://assets-cdn.github.com/images/modules/logos_page/Octocat.png)) was born to
be an accomplice to Git until it became the largest web hosting site for source code or something.
[Then the rest is history, I guess](https://github.com/ten).
Now onto the main branch of this post...
## What is Git?
Git is a version control system with a command line interface (mainly) that uses a [distributing version control system (DVCS)](https://en.wikipedia.org/wiki/Distributed_version_control).
Which means everyone involved will have a clone of the project to revise it in their own way then merge them when necessary into
the server computer.
DVCS also makes use of your local resources instead of relying on a network, meaning you can do some version control-related stuff
offline. Compared to other CVS, this is a very huge advantage and it is one of the reasons why Git (and other DVCS) are quite fast
in terms of doing an operation.
If you have read *About Version Control* section on *Pro Git* and understood what version control is and what are some ways to
implement this system, you'll figure out that what makes Git different from other VCS is the way how Git treats its files.
## How do I use it?
If you're on a Windows OS or Mac OS, you would have to download Git [here](https://git-scm.com/downloads) and install it.
Else if you are on a Linux-based OS, chances are Git is already installed --- makes sense as Git was developed for Linux. But
in case that you did not have Git for some reason, you can download and install it through the installed package manager of
the OS.
Anyway, the thing we need to know about when using Git is that it is uses CLI, that means we just have to get the command
line to utilize it and be comfortable with seeing just text (although there are GUI version of it).
Git has a plethora of commands so I would recommend to memorize a handful of important and useful commands and do make good use of
the man page of git and `git --help` a lot. Being a decent programmer does not mean they know all of the commands and syntax of
the language, they usually refer to documentation since there are other things other than syntax to worry about and there just a
ton of them --- just a self-reminder.
While speaking of Git, we cannot really avoid not talking about GitHub, a web hosting site that implements Git as a source version
control tool and what makes Git to be a rising star in the version control industry.
And while at on the subject of GitHub, I would suggest creating a GitHub account for it, if you do not have one already.
### Setting up Git
Now you have Git, it is time to configure Git which will be explained later. For now just run this command and fill it with
appropriate values:
{% highlight bash %}
git config --global user.name "Your Name"
git config --global user.email mail@example.com
{% endhighlight %}
This command sets the name and email for all and upcoming repositories to be filled each time you commit.
If you want to have a different configuration of name and email in a single repository, you can go to the directory of the project
of your choice then run the command without the `--global` option.
Why do you want to do this? Because each time you would send the updated files on a remote repository, it would ask you to
fill the commit with the needed information such as your name and email to be associated. Also, it is obviously tiring, so there's
that.
### Obtaining a repository
OK! Let's get into actually using Git. For starters, you can get a Git repository by either making your current directory to
be a Git repository or cloning one from some place. For now, let's use with the former which you can do that by:
{% highlight bash %}
git init
{% endhighlight %}
And now you have a Git repository that is ready. A more detailed explanation on `git init` is that it creates the necessary files
that basically serves as a local database to be referenced in case you want to push it to the remote repository (i.e. GitHub,
BitBucket).
Well, now that we have ourselves a Git repo, what now?
### Checking files
We add some files in it, of course! Just add whatever files to your desire (of course, consider what files are you going to
include). Next, run this command:
{% highlight bash %}
git status
{% endhighlight %}
Assuming it is a new Git repository, you will see something like:
{% highlight git %}
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
dog.ods
folder-1/
poop.txt.txt
nothing added to commit but untracked files present (use "git add" to track)