How to Get Started with Git Bash on Windows

choubertsprojects

The Best WordPress plugins!

1. WP Reset

2. WP 301 Redirects

3. WP Force SSL

Git Bash is an open-source terminal emulator for Windows. It offers a variety of features to make it easy to access Linux commands and use Git with your favorite text editor, Visual Studio Code.
Git Bash can be downloaded from the Microsoft website and installed without any additional software or drivers required. There are some limitations though: you must have administrator privileges in order to install this application on your computer, which means that only users who manage their own machines will have access.,

The “git bash windows” is a command-line tool that allows users to interface with their Git repositories. It has been available on Windows since the release of Windows 8.1.

How to Get Started with Git Bash on Windows

Did you know that you may use Linux tools right from your Windows desktop? Perhaps you’re searching for a terminal where you can execute Git and Linux commands separately. If that’s the case, give Git Bash a try (Bourne Again Shell).

In this article, you’ll learn what Git Bash is, how to install it on Windows, and how to use the Git Bash terminal to perform some simple commands.

Prerequisites

This lesson is shown on a Windows 10 PC version 1909, but any other Windows PC version (7-8.1) will work.

What exactly is Git Bash?

Let’s go through what Git is before we go into Git Bash. Git is a version control system for managing software development changes. Operating systems, like macOS and Linux, come with a command-line terminal where you may execute Git and Linux instructions directly. However, the Windows command prompt, which is a non-Unix terminal, is available for Windows.

How do you use Windows to perform Git and Linux commands? Git Bash should suffice. Git Bash is a Git emulation layer that allows Git to perform Linux commands on Windows PCs. An emulator allows one computer system to mimic the behavior of another.

Git Download and Installation (Bash)

Let’s look at how to obtain and install Git Bash now that you know a bit about it. The Git program for Windows OS may be downloaded in three different methods, as described below.

You may use any of the three methods to download Git, but this guide will utilize the official website.

Let’s get Git installed on your Windows PC once you’ve downloaded it.

1. Run the downloaded installer and keep clicking Next until you reach to the Select Components box.

2. Next, tick the boxes next to any extra components you wish to install. Leave the default options chosen, as indicated below, and click Next.

Installation of Additional Components Installation of Additional Components

3. Click Next after leaving the default for creating a shortcut in the start menu folder.

Choosing a Start menu folder Choosing a Start menu folder

4. Click Next after selecting Use Notepad as Git’s default editor from the drop-down list as a default editor to use with Git. ./gitconfig and all Git files will now open in Notepad by default.

Selecting Git's Default Editor Choosing the Git Default Editor

5. Set the default branch name (main) for new repositories to Override the default branch name for new repositories. Git will use this branch name by default when you create a Git repository.

For Git repositories, the default branch name used to be “master.” However, many individuals regarded the term “master” to be objectionable. So, in response to the Software Freedom Conservancy’s recommendation, GitHub added the ability to modify the default branch name when creating a Git repository.

Choosing the Default Branch Name Choosing the Default Branch Name

6. Select Git from the command line as well as the 3rd-party software option so that the Git command may be run from a variety of tools. Command Prompt, PowerShell, or any other third-party software tools, as well as the Git Bash interface, are some of such tools.

Choosing a Console to Execute Git Commands Choosing a Console to Execute Git Commands

7. Click Next after selecting the Use the OpenSSL library option to have Git verify certificates using OpenSSL. OpenSSL is a cryptography library that includes open-source SSL and TLS implementations.

Select the User the native Windows Secure Channel library option instead if you’re using Git in an organization with enterprise-managed certificates.

SSL/TLS library selection for HTTPS connections SSL/TLS library selection for HTTPS connections

8. Leave the default settings alone. Click Next after checking out Windows-style and committing Unix-style line ends.

When you click return on your keyboard after running a Git command, Git will insert an invisible character called line ending if you specify “Windows-style” line ending conversions. Git may deliver surprising outcomes when distinct contributors make modifications from different operating systems.

Option for selecting line ends Option for selecting line ends

9. Click Next after selecting Mintty (MSYS2’s default terminal) as the preferred terminal emulator for running commands. MSYS2’s default terminal is Mintty. MSYS2 is a set of tools and modules that offers a Unix-like environment for software distribution as well as a Windows development platform.

Choosing a standard terminal emulator Choosing a standard terminal emulator

10. Set the default behavior of the git pull command to Default (fast-forward or merge). The git pull command gets and integrates changes from a remote repository into the current branch, and is a shorthand for git fetch and git merge.

You may wish to merge a new branch into master. If this is the case, Git will merge straight using fast-forward, bypassing the git fetch and git merge commands. Only if there are no commits on master since you started the new branch is the merging feasible.

Choosing the git pull command's default behavior Choosing the git pull command’s default behavior

11. Click Next after selecting Git Credential Manager Core as the default Git credential assistant. Git credential helpers are third-party apps that ask Git for data such as usernames and passwords. These input data might be temporarily saved in memory or permanently kept on disk.

Git Credential Manager Core is a.NET framework-based Git credential manager that supports multi-factor HTTPS authentication.

Default Credential Manager is selected. Default Credential Manager is selected.

12. Click Next after leaving the additional features at their default settings, as indicated below. To offer speedy results when running Git operations, the Enable file system caching option is selected.

Adding more options Adding more options

13. Click Install, leaving both choices below (pseudo console and built-in file system monitor) at default since they are still in the experimental stage.

Support for experimental alternatives Support for experimental alternatives

14. Click Finish to complete the installation and end the installation wizard.

Complete screen of the Git setup wizard Complete screen of the Git setup wizard

15. To run Git Bash terminal, right-click on your desktop and choose Git Bash Here from the context menu, as shown below. One of the simplest methods to do so is to launch Git Bash from your desktop, but you may also do it by right-clicking on a folder.

Git Bash from the Desktop Context Menu Git Bash from the Desktop Context Menu

16. Verify that Git Bash is installed and up to date by using the git command below (—version).

The current Git version in this lesson is 2.32.0.windows.2, as you can see below.

Installing Git Bash and verifying it Installing Git Bash and verifying it

Using Different Terminals to Run Git Commands

It’s time to learn some Git commands now that you’ve installed Git Bash on your computer. The Git Bash terminal isn’t the only place where you can run Git commands. Did you know you can use the command prompt to perform Git commands? Yes!

To declare variables visible on both terminals, execute Git commands on both the Git Bash console and the command prompt.

1. Open the Git Bash terminal by pressing the Start button, then typing git and selecting Git Bash.

Starting Git Bash using the Start ButtonStarting Git Bash using the Start Button

2. Run the git config command below to set your git username to your name (YourName) (user.name). The git config command manages Git’s configuration variables, which affect how it appears and works.

To specify the configuration variable (YourName) in the /.gitconfig file explicitly, use the —global option with the git config command.

—global user.name “YourName” git config

3. Run the git config command below to add your email (“[email protected]”) as your git user email (—global user.email) in the /.gitconfig file.

4. Run the git config command to list (—list) all Git configuration variables in the same command prompt window.

The variables in the /.gitconfig file are available and shown on the command prompt, despite the fact that they were introduced through different interfaces.

Viewing Global Variables Added Through Various ConsolesViewing Global Variables Added Through Various Consoles

Using Git Bash to Execute Linux Commands

All Git commands function in both Git Bash and the command prompt, as you can see. Let’s try executing a Linux command on the Git Bash terminal, as Git is offered as a Unix-style command-line environment!

To list the files and directories in the working directory, use the ls command in both the Git Bash shell and the command prompt.

The Git Bash terminal produces an output, however the command prompt throws an error indicating the ‘ls’ command is not recognized, as seen in the pictures below.

In Git Bash, running a Linux command produces a result. In Git Bash, running a Linux command produces a result.

Running a Linux command in the Command Prompt Error Running a Linux command in the Command Prompt Error

You may use the command prompt to perform Linux commands if you first change the directory to C:Program FilesGitusrbin.

To change the working directory to C:, perform the instructions following from the command line. Run the ls command from the program FilesGitusrbin.

cd C:Program FilesGitusrbin # Change directory to where Linux utilities are kept ls # Linux command that lists all files and directories in the current working directory

You can see in the screenshot below that the ls command did not return an error this time, but instead delivered results.

Using the Command Prompt to Run Linux Commands Using the Command Prompt to Run Linux Commands

Conclusion

The goal of this tutorial is to explain what Git Bash is and how to install Git software. You now know what Git Bash is and how to execute Git commands from both Git Bash and the command prompt.

Which console would you use the next time you need to perform Git commands?

Git Bash is a command-line tool that allows users to open and work with the Git repository. To open Git Bash in Windows, click on the “Windows” icon at the bottom of your desktop. Click on the “Git Bash” option in the menu that appears. Reference: how to open git bash in windows.

Related Tags

  • download git bash for windows
  • git bash commands
  • git bash download
  • git for windows
  • how to use git bash

Table of Content