Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Git Essentials ??? Second Edition

You're reading from   Git Essentials ??? Second Edition Create, merge, and distribute code with Git, the most powerful and flexible versioning system available

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781787120723
Length 238 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ferdinando Santacroce Ferdinando Santacroce
Author Profile Icon Ferdinando Santacroce
Ferdinando Santacroce
Arrow right icon
View More author details
Toc

Installing Git

Git is open source software. You can download it for free from http://git-scm.com, where you will find a package for all the most common environments (GNU-Linux, macOS and Windows). At the time of writing this book, the latest version of Git is 2.11.0.

Installing Git on GNU-Linux

If you are a Linux user, you may have Git out of the box.
If not, you can use the distribution package manager to download and install it; an apt-get install git command or equivalent will provide you Git and all the necessary dependencies in seconds, as shown in the following image:

Installing Git on Kubuntu

Installing Git on macOS

There are several ways to install Git on macOS. The easiest way is to install the Xcode command line tools. Since Mavericks (10.9), you can do this simply by trying to run git from the terminal for the very first time. If you don't have it installed already, it will prompt you to install it, as shown in the following image:

Clicking on the Install button will fire the installation process.

If you want a more up-to-date version, you can also install it via the *.dmg binary installer, downloaded from git-scm.com (it says mavericks in the file name, but just ignore that). Beware the macOS policies while installing packages downloaded from the Internet; to allow execution, you need to hold down CTRL and click on the package icon to open it:

Hold down CTRL and click to let macOS prompt you to open the package

After this, the installation will be very easy-it's just a matter of clicking on the Continue button and following the steps represented in the following screenshot:

Let's start the installation process

Click on the Continue button and then go on; a window like the one shown in the following image will appear:

Here you can change the installation location, if you need; if in doubt, simply click Install

Click now on the Install button to start the installation. After a few seconds, the installation will be completed:

Installation complete

Installing Git on Windows

While clicking on the Download button on http://git-scm.com, you will automatically download Git in either the x86 or the x64 variant. I won't go into too much detail about the installation process itself, as it is trivial; I will only provide a few recommendations in the following screenshots:

Enabling Windows Explorer integration is generally useful; you will benefit from a convenient way to open a Git prompt in any folder by right-clicking on the contextual menu.

You should also enable Git to be used in the classic DOS command prompt, as shown in the following screenshot:

Git is provided with an embedded, Windows-compatible version of the famous Bash shell (see https://en.wikipedia.org/wiki/Bash_(Unix_shell)), which we will use extensively. By doing this, we will also make Git available to third-party applications, such as GUIs and so on. It will come in handy when we give some GUI tools a try.

Use defaults for line endings. This will protect you from future annoyances while working on multiplatform repositories:

Now it's time to choose a terminal emulator for Git; I recommend using MinTTY (see https://mintty.github.io), as it is a very good shell, fully customizable and user friendly:

Now, let's look at some new stuff from the latest Git releases-that is file system caching, the Git Credential Manager, and symbolic links:

File system caching has been considered experimental until Git for Windows v2.7.4 (March 18, 2016), but now it is stable, and since Git 2.8 this feature is enabled by default. This is a Windows-only configuration option, and allows Git to be quicker when dealing with the underlying read/write operations. I recommend that you enable it for optimal performance.

Git Credential Manager (see https://github.com/Microsoft/Git-Credential-Manager-for-Windows) is included in the Git for Windows installer since v2.7.2 (February 23, 2016). Thanks to Microsoft, today, you can deal with Git users and passwords as easily as you can on other platforms. It requires .NET framework v4.5 or later, and perfectly integrates even with Visual Studio (see https://www.visualstudio.com/) and the GitHub for Windows (see https://desktop.github.com) GUI. I recommend that you enable it, as it saves some time while working.

Symbolic links is a feature that Windows has lacked from the beginning, and even when they were introduced in Windows Vista, they have highlighted many incompatibilities with with Unix-like symlinks.

Anyway, Git and its Windows subsystem can handle them (with some limitations), so, if needed, you can try to install this feature and enable it in configuration options (they are disabled by default). For now, however, the best thing is to not use them at all in your repository if you need to work on the Windows platform. You can find more info at https://github.com/git-for-windows/git/wiki/Symbolic-Links.

Git for Windows v2.10.2 (November 2 2016) introduced a new, built-in difftool that promises quicker diffs. I use it on a daily basis, and I find it quite stable and fast. Enable it if you want give it a try, but this is not mandatory for the purposes of this book.

Git for Windows will install it in the default Program Files folder, as all the Windows programs usually do.

At the end of the process, we will have Git installed, and all its *nix friends will be ready to use it.

Please keep an eye on the Release Notes to see what's new in the latest release.

You have been reading a chapter from
Git Essentials ??? Second Edition - Second Edition
Published in: Nov 2017
Publisher: Packt
ISBN-13: 9781787120723
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime