10th Aug

Taking the version controlling to the next level

Monday, August 10, 2015 - 08:57
4

What is Git?

Git is the most popular distributed version controlling system. It was created by Linus Torvalds for the Linux kernel development. Git has really powerful features, fast performance and support for non-linear workflows. Most major operating systems have support for Git (Windows, Linux and OS X). And the best of all: it’s free!

Is it good for me?

Of course! Think about it: you have the FULL COPY of that Repository. It has number of advantages:

  • If your Central Repository goes wrong, every developer has all the sources.
  • There is no need for developers to connect to the Central Repository. Instead, they can connect to a Repository which is on another developer’s machine (it can be even a shared folder!).
  • You can see the commit history even if you’re not connected to the server which makes tracking the progress extremely easy.

Okay, that’s nice. How to start with Git?

First, you need to install Git (https://git-scm.com/). It is a quite simple process. Second, you need a program which can clone a Repository. It can be your favorite IDE or a program designed for such tasks (like SourceTree (https://www.sourcetreeapp.com/)). We are going to use SourceTree, because it has a pretty nice user interface which makes everyday tasks so much easier.

Next: clone a Repository from your Central Repository. And.. you can start working. That’s all.

I finished my tasks. What’s next?

First, you need to check if anyone else has made changes since you cloned the Repository. You can do this with the Fetch button. What this do is compare your Repository against the Central Repository and show you the changes. It is important to note that this only shows the changes but not merge them into your Repository. If you want to merge the changes to your Repository, you can use the Pull button. So, you got the up to date Repository, completed your tasks and you’re ready to put the sources back to the Central Repository. As you may see in SourceTree, you have uncommitted changes. First thing you have to do is stage the files you want to include in the commit. Then make a Commit. It creates a snapshot from your work with added comment (commit message). Now, you have to Push these changes to the Central Repository.

That was a workflow when only a master branch exists. You can use Git with feature branches. In this workflow, you create a feature branch for every task you have. After you finished a task, you do all the steps you’d normally do but at the end, you have to merge it back to the master or developer branch. This workflow has a big advantage: user rights can be managed on branch level. Another option is that you create a pull request with your changes and one or more reviewers will take a look at your code and if they find it good, they will merge it to the master or developer branch.

What if I prefer commands?

You are not limited to use the buttons on the menu bar. If you click on the last button (Terminal), you will get a console window. It is basically a UNIX Shell with some limitations. With this, you can use UNIX style Git commands.

For example, you can set your name and e-mail address, so others can identify you:

git config --global user.name ”John Smith”

git config --global user.email ”john.smith@something.com

So… Git. Yay or Nay?

Personally, I think that Git is an amazing tool. With Git, you can manage branches extremely easy and the auto-merge feature works really well because Git is pretty good at resolving conflicts.          

Please note that there are so much more that you can do with Git. It’s just a basic introduction.

Comments (1)
4
4
Monday, August 10, 2015 - 15:13
Git just fails to work behind a proxy requiring NTMLv2 authentication. It claims to use the CURL library, but while on the same machine CURL can connect via the proxy Git can't. It just can't be set up to use the proxy properly. I had to install cntml to proxy the Git requests to the real proxy and hardwire the password into the cntml config (fortunately it's stored encrypted). So Git is wonderful as long as there's no obstacle between you and your repository server ;)