Hey folks.

So, for my first post, I want to talk with you about git control version. I know many people don’t know what is git, The most people and friends are from college, I hope that help you to understand what is “git” and its purpose.

Git, it’s a distributed version control system. That’s okay, but what this means, right? This means what git take care of the state of your files. It tracks any change in your crawled archive.

(I will consider you have the git installed in your pc. If you don’t have please follow this steps)

So let’s see how it works in practice.

Let’s say you have a hello_git.txt: terminal

And, of course, you want to track it. What you should do is open your terminal and navigate until the folder of your archive and type git init . like this: terminal

With this we start a repository in this folder, It means that git is looking at our folder now, but it not tracking our files yet. If we type git status we have something interesting. Look: terminal

The git warning us, “hey man I not tracking your file changes” so we can ask to git take care our file typing git add hello_git.txt. Now if we run git status again we will see this: terminal

If we want git to take care of everything in our folder, we could have type git add . (witch the dot).

So now git is watching our file, we can register this moment with a commit typing git commit -m 'my first commit', this command register the state of our file with a message. Now our git status was changed and we can see our commit registered typing git log. terminal Congrats for your first commit \o/.

Okay, but what this means? This means we have a register in the time of our file. If we change our file and type git status we will see this. terminal

Are you see? It says “hey man your file was changed would you want to track this alteration for a new commit?”. Cool, we will accept the suggestion and will add the file, after that, do a new commit. terminal

type git log and see. terminal

cool, we have now two commits, but… What is the purpose of this? Let’s say you want to know what the differences between your two commits (so many lines, you don’t remember haha). With that registers in the time in form of commits we can compare versions of out file in the time with git diff command for example, for this we need the unique code of two commits (we get this with git log): terminal

So now, git tell us “hey bro the difference between this two commit is this two lines”. Imagine this function in a big change in a real project. Let’s say we did shit in our last alteration, we did a commit and the things don’t work more. What do we do? We cry? maybe… haha Don’t worry, if we do a shit but we know the last commit work, we can do a git reset --hard, look that: terminal

See the git log we have one commit from the beginning and the command cat shows what have in our file. Our first version with just “Hello Git!”.

So, I hope this helps you to understand the extremely basic of git. This is the part one I will write a part two, with git branch and merge. If you have some question, please leave a comment, I will be happy to ask questions.

ps: This is the first time I write an article in English, I sure I’ve killed the grammar. If you want to help me correcting something you can fork this article on my GitHub and correct or just leave a comment for help me.

Thanks a lot, see you in part 2!