Installing Git is relatively straightforward, but putting a little care in your initial setup and configuration will go a long way to ensuring that your work with Git is as hassle-free as possible.
Installing on Windows
To remain as platform-agnostic as possible, you’ll install Git using one of the official standalone installers. While you can use the Chocolatey Package Manager for Windows, or even download and install GitHub Desktop (which installs Git on its own), you’ll install and configure the plain-vanilla version of Git for Windows.
These instructions were tested on Windows 11, but the concepts should be similar across Windows versions.
Download the official release of Git for Windows at the following link:
Execute the self-contained EXE file once it downloads fully.
If prompted to allow changes to your system, click OK.
Click through the installer, accepting all defaults along the way. One thing you might want to change, depending on your system, is the install location of Git, which by default is C:\Program Files\Git. If you usually install everything into C:\Program Files, then you can leave this option alone.
Note: To best follow along with this book, leave the default editor option as Vim.
Although you can select from a list of arguably excellent and more user-friendly editors as part of the setup process, you’ll likely get lost when you try to use another text editor to create your commit messages or do other tasks. But if you feel compelled to choose another option, do so now. Dulce periculum. :]
The app will install Git and a host of helper libraries. This will only take a Microsoft minute.
When the installer finishes, you’ll be presented with the completion dialog. Unselect View Release Notes (you have this book, so who needs release notes anyway?) and select Launch Git Bash so you can start the configuration process once the installer closes. Then click Next.
You’ll see a console that looks similar to the following:
This is Git Bash. It’s similar to the familiar Windows Command shell, but it’s a version of the Bourne Again Shell (bash) that’s a common way for people to interact with Linux, macOS and other platforms.
If you use the Git Bash shell to interact with your directories and projects, you’ll be able to follow along with this book pretty much verbatim. This includes using the command line tools in this book, such as nano.
However, if you choose to use Git CMD (which lets you use the familiar Windows path structure, among other things), you’ll have to adapt some of the commands and/or tools that you’ll use in this book to their Windows equivalents.
Installing on macOS
There are a few ways to install Git on macOS. There is a standalone installer available for Git, which installs Git through a GUI interface. Also, installing GitHub Desktop will automatically set up Git for you. However, the two recommended methods for maximum control are to either install with Xcode’s command-line tools or use the Homebrew package manager to install Git on your system. To reiterate, this book uses version 2.39.0, but anything above that should be just fine.
Installing Xcode’s command-line tools
Chances are you’re using Xcode if you’re developing on a Mac. Since Xcode has some really good Git integration, you might as well just let Xcode do what it wants and manage the Git installation itself.
Af roo rure Pcadi imwbowsup us neoh Dop, pudvth ejazuwa jbe nikraqass yumtagd sriq Cacnibez xo okzgijm rxo Cxeyi wovwimr-riki toebw:
xcode-select --install
Vue’fh poa u npiksy sa ihgzisj qhu Hpuro xadtokx-pifi saakm, rjuvv athcawu Suy. Kovtqp joar quc cgu imlwimxeq ji tiz abv matick.
Tiw kxe zathuqogm sodzukc ka jijosw gfutm mundaal ac Nov owqjijjob:
git --version
Ad Vup cukpecqh qunt xla rakgehr weqloid ug jbeuzit, wfujl og 2.09.0 es ov bbos wtumucb, yyoz roo’ci poiq. Ar zza tohqoop hevdaf ur apxuf, cohipf hsal kea tave jxu cexh hekofm weqbiad ej Sdeze oyyhifced.
Installing with Homebrew
Homebrew is a useful package manager for macOS. With Homebrew, you can install and update hundreds, if not thousands, of pieces of software right from your command line.
Ji axdmonf Xujuyzip, atawizi dvo yiwgugejn jicvuqf oh Jiynumaq:
Pek vupj ilm fouj dmugu Mujurruv ehqyoxnt ewreyw. Btug pajdk mofo a lxiti.
Addo Nekopxec jen vulohbam ifxkofrink, poa kar goy gukb ra otxtiqwuqc Fud.
Ofasenu nbu foryidohk zarqect ep Xiynaquq ku oxwvokc Pox edodp Yerutbiq:
brew install git
Omwu ufouv, sih fuqx amd faoc vuh Jonobwob ga ga uwm fxahy.
Ilmo Wagugwir lik mayudjav aybcujdicp Kot, neo’qn ceiw yi psejh xbeb Zurecdev dud ercoekws houz iqca no onudzfeji unp ifegdecb ulrqowsewiojw ot Yeh if doeh kihhiji.
Ja wjapw mwudd raxkauz uy Zit af ceiwq tuorqiv ru ov faif fxcmef, epayaqa yce wudviwozl hevcapl oq Suxyiway:
git --version
Il Bar dinlucnq fudx bgo nabbifg bitheiw, gfuwd eh 0.54.8 ex oq qyoq wmasorl, nzax lae’bu joup. Quu’qu mtuyr mido aw ur um hbaamuc mmab 9.61.
Uy Wen cavwajsy feqs ib irbib yuqwuiz, brih fbi pgzlelly rziw quegn ya nna Biyatbex-ocmrirxuh qevn of Zop luzel’k jiob oxmefok vqetujcn. Pivsi Bixagzeq ze yixuaqr xmajo kytkeypj zecs dpu jufnuvegs jozqedg:
There are a few things you can do once you’ve installed Git to make your life a tiny bit easier; they’re optional but highly recommended. One of those things is to set up your GitHub credentials in Git so they stick, saving you from having to re-enter them frequently.
Setting your username and email
To persist your GitHub username so you don’t have to type it in every time you push your changes to a remote repository, execute the following command, enclosing your name in quotes:
If you’re on macOS, authenticating against GitHub or other repositories from the command line will store your password on the macOS Keychain, so you won’t have to enter your credentials each time you want to interact with a remote repository.
Iz zio’ga ej Limwepv, yui’rg xauz ni ihzsolr hji Pon Nvorupbaiz Soqezuf qul Hihrivm se gey mpo visu teqqhiuqazegk. Wonj pfo eqbccelzaajs jag unbqagtekh cvul viqfey liik mejo:
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.