How to Install Git and Git Bash in Windows

[ad_1]

Git Bash is a terminal emulator for Windows, used for a Git command line experience. With Git Bash, you can work on any changes in the code in the terminal itself, without the need for another coding environment, such as Atom, Notepad++, etc. Follow the various methods in this guide to install Git and Git Bash on Windows. When you add Git Bash as a program in Windows, it installs the entire Git version control system.

Good to know: need a text editor? Check out this list of the best cross-platform options for programmers.

How to Install Git Bash/Git in Windows

There are four different methods to install Git Bash/Git in Windows, and each has its advantages. The first method is the complete instructions for a regular Git installer, while the other methods are shortcuts that lead to the same results.

1. Using Git Installer for Windows

Installing Git for Windows is a breeze, but you should carefully check the steps to avoid syncing errors later.

  1. Click the Windows link on the download page.
Official downloads page for Git Bash for Windows and other operating systems.
  1. You will see multiple download links. If you’re looking for a regular installer, choose the latest 64-bit version for Windows.
Download link for latest version of Git Bash for Windows.
  1. Accept the GNU General Public License.
Git General license page for agreement for Windows users.
  1. Select a destination location on your Windows device.
Select Destination folder for Git in Windows 11 system.
  1. Select the components you want to install and clear the ones you don’t. At the minimum, you will need to enable the options for “Git Bash,” “Git GUI,” “Git LFS (Large File Support),” “Associate .git configuration files with the default text editor,” and “Associate .sh files to be run with Bash.” In most cases, these required options should be enabled by default.
Select the components to be installed in a Git setup for Windows.
  1. A Git folder will be created as the default in Program Files. You can opt not to create a Start Menu folder.
Disable start menu folder for Git installed in Windows.

Tip: check out these useful YouTube channels that can teach you how to code.

Customizing Your Installation

In the next step, you will have the option of choosing the default editor by Git.

  1. While Vim is the default editor, you will find many other options, such as Notepad++, Atom, Visual Studio Code, and Sublime Text. For this tutorial, we are using Vim.
Selecting Vim as default text editor for Git installation in Windows with other options visible.
  1. Select the initial branch name or leave it up to Git. It’s safer to select “Let Git decide.”
Let Git decide chosen as the option to adjust the initial branch name in new repositories.
  1. Select the recommended PATH environment of “Git from the command line and also from 3rd-party software.”
Select Git from command line option for adjusting path environment.
  1. Select “Use bundled OpenSSH” as your secure shell (SSH) client executable.
Choosing bundled OpenSSH as SSH executable for Git to use.
  1. Choose the HTTPS transport backend, “Use the OpenSSL library,” for superior authentication.
Select OpenSSL library as HTTPS transport backend for Git to use.
  1. Another Git convention is to configure line endings in text files. Select “Checkout Windows-style, commit Unix-style line endings.”
Selecting checkout Windows-style commit Unix for Git's line ending conversions.
  1. You need a terminal emulator to use with Git Bash. Opt for MinTTY, the default terminal of MSYS2, instead of your Windows console window. This keeps Git programs separate from what you do in Command Prompt.
Use MinTTY as default terminal emulator for Git Bash setup in Windows.
  1. Select the “Default” option for the behavior of “git pull” requests.
Choose default behavior of Git pull as default fast-forward and merge option.
  1. To manage your GitHub and other third-party credentials, select “Git Credential Manager.”
Choose Git Credential Manager as default credential helper to be configured.

Tip: if you’re new to Git, get up to speed with our full beginner’s guide.

Additional Options

There are also some extra options that you need to configure in a regular installation of Git for Windows.

  1. Select “Enable file system caching” for enhanced performance boost.
Enable file system caching for configuring extra options in Git.
  1. It’s safe to ignore the experimental options, such as pseudo consoles.
Experimental features to be tried in Git: pseudo consoles, file system monitor etc.
  1. It will take a few minutes for the Git installation to finish.
Git installing on a Windows 11 computer.
  1. You can launch Git Bash after the Git Setup Wizard is finished.
Git installation finished on Windows 11 computer with message displayed in Wizard.
  1. Alternatively, locate the Git Bash application in Windows search or open the executable from the folder where it is installed.
Git Bash shown in File Explorer window under Git folder saved in Program Files.
  1. The MinTTY terminal emulator should be visible. This will help you keep your Git operations separate from the remaining PC functions. The MinTTY window feels the same as the command terminal.
Ls command in Git Bash console window.

Tip: did you know that you can add screenshots and animations to GitHub, pull requests and operate them from your Git Bash window?

2. Using Git Portable Version

Apart from the lengthy regular installer, Git also has a portable version for Windows, which is very handy.

  1. Go to the Git Download for Windows page and click the Windows Portable download link.
Download links for Git's portable version in Windows.
  1. Save the Portable .ZIP file in a folder of your choice.
Git portable version available in Windows 11 downloads folder.
  1. You can change the Git portable installation destination by clicking the three-dot icon.
Portable Git installation location in Windows 11.
  1. Wait for the portable installer to extract completely.
Extracting portable version of Git in Windows with percent number display.
  1. Once the process is complete, you’ll find the portable folder nested inside “Git Bash Install Windows.”
Portable Git folder location in Windows.
  1. Launch the Git Bash application from the PortableGit folder, then save it to a USB drive, if you wish.
Launching Git Bash application from PortableGit folder.
  1. MinTTY emulator describes itself as a portable terminal, but it’s no different than a regular terminal, and you can use all your Git commands here.
Git Bash portable version open in Windows 11.

Tip: do you use portable apps often? Learn how to add them to Windows startup.

You can use the Winget command-line tool to install Git/Git Bash in Windows.

  1. Install the App Installer Microsoft Store application on your computer.
App Installer visible in Microsoft Store.
  1. Open Command Prompt in administrator mode.
  2. Type winget to verify that the App Installer program has been installed correctly. It will show various commands you can use with Winget.
Type Winget in Command Prompt Administrator mode to review its options.
  1. Install Git using Winget in Command Prompt by typing the following code:
winget install --id Git.Git -e --source winget
Downloading and installing Git via Winget in Windows 11 Command Prompt.
  1. It can take up to a minute for Git to install through Winget in the Command Prompt. You may also find an installer pop-up window.
Installing Git via Winget inside Command Prompt window.
  1. Check for a “Successfully installed” message in Command Prompt.
Git successfully installed message in Command Prompt window.
  1. Once the Git Setup Wizard finishes installing Git, launch Git Bash or open the program terminal from the Windows search box in Administrator mode.
Search for Git Bash app in Windows 11.

Good to know: are Windows 11 widgets not working for you? Try these solutions.

4. Chocolatey

Chocolatey is a Windows program in PowerShell that can quickly help you install the full version of Git/Git Bash. It’s like a wrapper around any target application that is being installed.

  1. Open PowerShell in Administrator mode.
  2. Install Chocolatey in Windows using the following command. You will not get any message confirming that installation was successful. Once the process is complete, close the PowerShell window, then restart.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Latest version of Chocolatey installed via PowerShell.
  1. In the new PowerShell window (Administrator mode), type the following to install Git using Chocolatey.
choco install git.install
Installing Git via Chocolatey program in PowerShell window.
  1. Click “A” or “Y” to grant the permissions required by Chocolatey.
Click A to install all scripts of Git via Chocolatey in PowerShell.
  1. Once Git is installed on your device, you should see a success message in the PowerShell window.
Install Git message successful in Chocolatey package displayed in PowerShell window.

Good to know: want to learn how to use PowerShell? You’ll need this list of essential commands.

Frequently Asked Questions

What is the difference between Git and GitHub?

Git is an open-source version control system whose repositories are hosted on GitHub, an online collection of Git source codes. GitHub is owned by Microsoft; however, its open-source nature has not changed because of the ownership. You need Git to run many GitHub projects, but it’s not true in the reverse, as there are alternatives to GitHub, such as GitBucket, GitLab and SourceForge.

What is the difference between Git and Git Bash?

Git is the original Unix-based version control system launched in 2005 by Linus Torvalds for tracking code changes in multi-user collaboration projects on Linux and Mac. Bash is another Linux-specific command-line shell based on Unix.

Microsoft’s operating system isn’t natively designed for Bash, a Linux-specific command-line shell. Therefore, Windows users must install Git Bash, a third-party software that is a customized Terminal Emulator designed specifically for Windows. With Git Bash, you can operate both Git and Bash together in Windows.

Can Git be completely uninstalled from Windows?

You can completely uninstall Git from Windows by uninstalling the Git Bash application from “Add or remove programs” in Settings or by going to Control Panel and clicking “Uninstall a program” under Programs and Features. Locate the Git folder in C: drive using the Windows search menu, then delete it. If you are using the portable version of Git in Windows, delete the Git folder, as no other installation was done.

Image credit: DepositPhotos. All screenshots by Sayak Boral.

Sayak Boral
Sayak Boral

Sayak Boral is a technology writer with over eleven years of experience working in different industries including semiconductors, IoT, enterprise IT, telecommunications OSS/BSS, and network security. He has been writing for MakeTechEasier on a wide range of technical topics including Windows, Android, Internet, Hardware Guides, Browsers, Software Tools, and Product Reviews.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

[ad_2]

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *

Call Us