What is Git Bash?

Git Bash is an application that gives users the ability to use Git commands on the Command Line Interface. Git Bash is a package that consists of Git, Bash, and some standard bash utilities. To understand Git Bash, understanding each aspect of the package is essential.

What Is Git?

Git is a version control system used to track changes in code during software development. Version control allows developers to save various versions of a file as they work on it; in the future, they can compare and roll back their files to any previous save points. Also, when a team uses version control, it helps keep track of who made changes to a particular file.

Changes on git working repositories can be tracked and used locally; you can also save updates in working repositories on online platforms like Github.

What Is Bash?

Every Operating System consists of a Kernel and Shell; the kernel is the actual program that interfaces with the hardware; it is the core of the OS. The shell in computing refers to the user interface that allows humans to interact with the kernel and hardware of your computer. There are two kinds of shells– Graphical User Interface (GUI) shells and Command Line Interface (CLI) shells.

Bash stands for Bourne-Again Shell; it is a Command-Line Interpreter for Unix-based Operating Systems like Linux and MacOS. In 1989, Brian Fox wrote Bash as a replacement of the Bourne Shell, named after its developer, Stephen Bourne. Currently, Bash is open-source software constantly improved by a large community of engineers.

How To Setup Git Bash

The setup procedures of Git Bash on Mac and Windows are slightly different; here are the steps below.

Setup Git Bash For Mac

Setting up Bash on MacOS doesn’t require any installations because MacOS is a Unix-based OS, and Bash is its default shell. Even though version 10.15 (Catalina) upward uses a slightly different default shell called Z shell or Zsh, there are many similarities, and you would not require switching to Bash.

To access Bash on MacOS:

  1. Open the Applications folder, then open the Utilities folder.
  2. You will see the Terminal application; open it, and you’re ready to go!
  3. You can run whatever Bash commands you desire on Terminal.

Install Git Bash For Windows

On Windows, the process is a bit more complicated because the default shell of the Operating System is known as PowerShell. To install and use git bash on Windows:

  1. We will need an application known as Hyper– a CLI built on HTML, CSS, and JavaScript (using the Electron.js framework). Hyper is the CLI that’ll allow us to use git bash.
  2. To download Hyper, go to hyper.is; your OS will be automatically detected, and you can click on Download Hyper for Windows.
  3. After downloading the hyper-setup.exe file, click on it to run the setup instructions.
  4. The installation is automatic, after which you should see the Hyper terminal window open on your PC.
  5. You cannot install git bash alone; to install it, we need to go to git-scm.com, the official website of git.
  6. On the git website, download the latest identified version for Windows.
  7. Open the downloaded .exe file and go through the default options. However, on the Select Components page, check the Git Bash Here checkbox before clicking Next.
  8. Click Next until you get to the Install button; restart your computer after the installation.
  9. To configure Hyper to use git bash, you need to visit this GitHub link and copy the entire code in the hyper.js file.
  10. Click the Options button on the top-left of your Hyper terminal; hover over the Edit option and select Preferences.
  11. The program will open a configuration file; if it is not blank, press Ctrl + A to select all and clear it. 
  12. Paste the configuration you copied from the GitHub repo and save the file.
  13. You’ll notice Hyper updating its configuration; close Hyper and open it again.
  14. You’re now ready to use Git Bash on your Windows PC.

Note: You can also use hyper on MacOS; many MacOS programmers use it because it allows users to customize its functionality using plugins and themes.

Some Common Bash Commands

Working knowledge of the Command-Line is essential for every developer. The Command-Line gives you better control– allowing you to exert more power over the computer hardware. However, on a day-to-day basis, using the command line makes it easier and faster to do many ordinary things on the computer.

Here are some common Git bash commands and what they do:

SNCommand NameUseSyntax
1lsIt lists the directories in your current location.ls
2touchIt’s used to create a new filetouch sample.txt
3mkdirIt’s used to create a new directory in the current locationmkdir New Folder
4cdIt’s used to change your current working directory to a specified locationcd Users\Stephen\Desktop
5..It’s used to go back to the immediate parent directory..
6exitThis command will close a terminal window, end the execution of a shell script, or log you out of an SSH remote access session.exit
7clearIt is used to clear all previous commands and output on the terminal windowclear
8manThis is used to show instructions on what a command does; you type man and put the command name in frontman touch  
9pwdIt is used to print the working directory you’re currently onpwd
10locateIt used to search for a file or directorylocate sample.txt

Read More: What is DevOps?

Leave a Comment