Version Control System

Install Git on Windows: The term “git” was not used as the name of a cmdlet, function, script file, or executable Program recognized

Git-recognized

Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. The most widely used modern version control system in the world today is Git. Git is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel. Having a distributed architecture, Git is an example of a DVCS (hence Distributed Version Control System). Rather than have only one single place for the full version history of the software as is common in once-popular version control systems like CVS or Subversion (also known as SVN), in Git, every developer’s working copy of the code is also a repository that can contain the full history of all changes. It is worth noting that, Git was designed with performance, security, and flexibility at heart.

Git is a very supported open source project and the project maintainers have shown balanced judgment and a mature approach to meeting the long-term needs of its users with regular releases that improve usability and functionality. The quality of the open-source software is easily scrutinized and countless businesses rely heavily on that quality. Kindly refer to some of these related guides: How to install Git on macOS, how to clone a repository and install software from GitHub on Windows, Panic: Failed to register the GitLab-runner, you may be having network issues, and how to install and uninstall Docker Desktop on Windows 10 and Windows Server.

The following error below was prompted because Git was not installed on Windows. Also, there is no environment variable or path defined where the docker executable programs are located.

Furthermore, Kindly refer to these related guides: How to create and deploy a local Registry Server with Docker Image, how to Pull your first Nginx Container Image from Docker Hub and deploy it to your local machine, Azure DevOps and GitHub integration for Docker and Kubernetes deployment, how to create a static pod in Kubernetes, and how to install, register and start GitLab Runner on Windows.

section_end:xxxxxxxxx:prepare_script
section_start:xxxxxxxxx:get_sources
Getting source from Git repository
Fetching changes with git depth set to 50...
&: The term "git" was not used as the name of a cmdlet, function, script file, or executable 
Program recognized. Check the spelling of the name, or that the path is correct (if included), and
repeat the process.
In C:\windows\TEMP\build_scriptxxxxxxxxx\script.ps1:221 Zeichen:3
+ & "git" "config" "-f" "C:\GitLab-Runner\builds\xxxxxxxxx\0\documentati ...
+   ~~~~~
    + CategoryInfo          : ObjectNotFound: (git:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 
section_end:xxxxxxxxx:get_sources
section_start:xxxxxxxxx:cleanup_file_variables

Install Git on Windows

However, To resolve this issue, we must install Git on Windows, as shown below. Browse to the official Git website and click on the 64-bit Git for Windows Setup as shown below.

Screenshot-2021-10-05-at-20.23.10

Moreover, Browse the downloaded setup file as shown below. Double-click the file to extract and launch the installer.

Screenshot-2021-10-05-at-20.24.03

In addition, Accept the User Access Control if you have it enabled in your environment. Nonetheless, Click on Yes to proceed. You may want to learn how to turn UAC on or off in Windows.

Screenshot-2021-10-05-at-20.24.31

Consequently, Please review the GNU General Public License, and when you’re ready to install, and then click on Next.

Screenshot-2021-10-05-at-20.24.52

Similarly, The installer will ask you for an installation path. Nevertheless, I will be leaving the default location unless you have reason to change it, and click Next.

Screenshot-2021-10-05-at-20.25.09

Therefore, In the component selection window, for me, I will leave everything as default. Additionally, Click on Next to proceed

Screenshot-2021-10-05-at-20.33.34

Furthermore, As you can see, the installer will offer to create a start menu folder. Just click on Next.

Screenshot-2021-10-05-at-20.33.51

However, Select a text editor you’d like to use with Git. Moreover, Use the drop-down menu to select an editor of your choice. I am okay with the default editor. Click on Next to continue.

Screenshot-2021-10-05-at-20.34.11

In addition, The next step allows you to choose a different name for your initial branch. Nonetheless, The default is ‘master.’ Unless you’re working in a team that requires a different name, leave the default option and click Next.

Screenshot-2021-10-05-at-20.35.04

Customizing PATH Environment for Enhanced Command Line Control

Consequently, I will be selecting the second option. This allows you to change the PATH environment. Similarly, The PATH is the default set of directories included when you run a command from the command line. Leave this on the middle (recommended) selection and click Next.

Screenshot-2021-10-05-at-20.37.48

I will be selecting the Use bundled OpenSSH as shown below. I will click on Next to proceed.

Screenshot-2021-10-05-at-20.38.33

Nevertheless, The below window relates to server certificates. Most users should use the default. Therefore, If you’re working in an Active Directory environment and you have a Certificate Authority server set up, you may need to switch to Windows Store certificates. Click Next.

Screenshot-2021-10-05-at-20.38.58

Additionally, I will be selecting the very first option as it converts line endings. It is recommended that you leave the default selection. Furthermore, This relates to the way data is formatted and changing this option may cause problems. Click on Next.

Screenshot-2021-10-05-at-20.39.40

However, I will be using the second option. Click on Next to continue.

Screenshot-2021-10-05-at-20.51.52

Moreover, The installer now asks what the git pull command should do as described in the image below. In addition, The default option is recommended unless you specifically need to change its behavior. Click Next to continue with the installation.

Screenshot-2021-10-05-at-20.52.52

Please decide on which credential helper to use. Nonetheless, Git uses credential helpers to fetch or save credentials. Consequently, Leave the default option as it is the most stable one, and click Next.

Screenshot-2021-10-05-at-20.53.28

Similarly, The default options are recommended. However, this step allows you to decide which extra option you would like to enable. Nevertheless, If you use symbolic links, which are like shortcuts for the command line, tick the box. Click Next.

Screenshot-2021-10-05-at-20.54.07

Therefore, Below are experimental options. I will leave them unchecked and then click on install.

Screenshot-2021-10-05-at-20.54.32

Additionally, As you can see below, Git is currently being installed and on the next window, the installation is completed.

Furthermore, Git has various modes of use. Below are some of the ways to launch Git in your enviornment. To launch Git Bash open the Windows Start menu, type git bash, and press Enter or click the application icon as shown in the image below.

Now, you should restart your GitLab runner now that Git has been installed on ypur device. Then try to launch the build job again. It should work correctly. But if it doesn't, then follow the steps discussed below.

Set the PATH to point at the Git installation

You will need to set (add) the following paths to the system variable as shown below. The steps I will be describing are exactly the same on Windows 10 and Windows 11.

C:\Program Files\Git\bin\
C:\Program Files\Git\cmd\

In the Start Menu, and click on Settings as shown below.
– Alternatively, you can use the taskbar search, search for “environment variable” or right-click on This PC and then click on Properties .

Screenshot-2021-10-05-at-22.10.16

This will open the Settings window as shown below. Click on System

Screenshot-2021-10-05-at-22.16.00

Navigate to the About menu and on the right-hand window, click on Advanced System Settings.

Screenshot-2021-10-05-at-22.16.51

Click on the Advanced Tab as shown below. Click the “Environment Variables” button at the bottom.

Screenshot-2021-10-05-at-22.17.19

Let’s create a System Variable. To do this, click on New as shown below.

Screenshot-2021-10-05-at-22.18.21

ATH editor, add C:\Program Files\Git\bin\ and C:\Program Files\Git\cmd\ to the end of the list.

As you can see below, the system variable has been configured and set.

Screenshot-2021-10-05-at-22.22.36

Note: After creation, you can select the system variable and click on Edit to edit the path. Now, you can close the Environment Variable. Here is a similar guide discussing how to resolve “Running Docker commands returns Docker is not recognized as an internal or external command“.

Restart the GitLab Runner again

If you do not restart the GitLab-runner, the build job will still fail 🙂 To avoid this, please restart the GitLab-Runner as shown below. To do this via the Command line, please follow the steps discussed below.

Screenshot-2021-10-05-at-17.49.16

Ove via the services.msc. The same result will be achieved.

Screenshot-2021-10-05-at-17.48.02

Run the build Job again

As you can see below, I have run the build job again, everything is fine and the task passed (succeeded).

Job-succeeded

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x