Time for action – setting up Qt sources using Git

First, you need to install Git on your system if you don't already have it. How to do that depends on your operating system. For Windows, simply download an installer from package manager. For instance, on Debian-based distributions, just issue the sudo apt-get install git command on a terminal and wait until the installation gets completed.

Afterwards, you need to clone Qt's Git repository. Since Git is a command-line tool, we'll be using the command line from now on. To clone Qt's repository to a directory where you want to keep the sources, issue the following command:

git clone git://code.qt.io/qt/qt5.git

If all goes well, Git will download a lot of source code from the network and create a qt5 directory, containing all the files that were downloaded. Then, change the current working directory to the one containing the freshly downloaded code:

cd qt5

Then you need to run a Perl script that will set up all the additional repositories for you. If you don't have Perl installed, you should do that now (you can get Perl for Windows from http://www.activestate.com/activeperl/downloads). Then, issue the following command:

perl init-repository

The script will start downloading all the modules required for Qt and should complete successfully after a period dependent on your network link speed.

What just happened?

At this point in the qt5 directory, you have a number of subdirectories for different Qt modules (some of them were mentioned in Chapter 1, Introduction to Qt) each with a local Git repository containing the source code for the respective Qt modules and tools. Each of the modules can be updated separately if required.