Install the Git software.

Many development tools, such as XCode, come pre-installed with Git. It's a good idea to update Git even if you already have it installed on your PC. Each operating system has its own set of instructions. Rather than rehashing steps here, I recommend going to and following the instructions for your operating system to install Git.

You should be able to run the command "git" on terminal once you've installed it. You'll note that after installing Git on Windows, you'll get a new terminal named "Git bash." On Windows, this is a customized terminal/command window that attempts to replicate a Unix-style terminal. You're welcome to use it, however I've never had any problems using Git from the PowerShell window. Even on Windows, I believe you should use a Unix-like terminal because a lot of operations usually employ Unix-like commands intermingled with Git instructions. Most programmers mix and match them without even realizing it.

Git Configuration

Before you can use Git, you'll need to set up a few things. You'll need to provide a name and email address at the very least - this is your information, and it will identify you when you commit. The server-side repo, of course, authenticates you using the various Git authentication methods.

You can also set a default editor, and I strongly advise you to specify a line ending format as well.

Let's go over how to set up your computer for the first time.

There are three levels at which Git configuration can be performed. You can do this on a worldwide scale, affecting all users on your computer. You can do so in your user profile, which will have an impact on all work done on that user's profile. Alternatively, you can define at the folder level which settings should apply to which repos. These options are saved in a private file named ".gitconfig." Figure 1 shows an example of my gitconfig.

Let's start by setting up the login and email address. Here's how to do it. Keep in mind that you should use your own username and email address.

After that, we'll choose a default editor. Git uses Vim by default. Vim is popular among programmers. Unless I'm trying to exit Vim, I rarely need to restart my Mac. There are simply too many shortcut keys to keep track of. No, I don't mind it; in fact, when I'm ssh'ed into a Docker container, I might not be able to use anything like VSCode. However, I find VSCode to be more productive, so I'll make it my default editor as follows.

Of course, VSCode must be installed and on your path for the above to operate. VSCode now appears whenever you need to enter multi-line commit messages or perform anything that requires modification. Let's give it a shot. To edit all of your settings, run the command below.

As you can see, VSCode opens using your.gitconfig configuration. Because this isn't Vim, you don't need to memorize the "shift ZZ" shortcut to save and exit.

Figure 1 illustrates my settings, which include a few extra features that I haven't mentioned yet. It's possible that your settings file will differ somewhat.

Finally, we'll set up the end-of-line options. Let's have a look at this setting because it's quite significant. An end of line in Windows appears like this:

Have you noticed the difference? Carriage return and new line are frequently used by Windows. The reasons for this are ancient and so entrenched in Windows that it is unlikely to alter. However, when some of your developer pals use Macs and you use Windows, this poses a significant dilemma. In reality, while working on open source projects, this is almost always the case.