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:
- Open the Applications folder, then open the Utilities folder.
- You will see the Terminal application; open it, and you’re ready to go!
- 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:
- To download Hyper, go to hyper.is; your OS will be automatically detected, and you can click on Download Hyper for Windows.
- After downloading the hyper-setup.exe file, click on it to run the setup instructions.
- The installation is automatic, after which you should see the Hyper terminal window open on your PC.
- You cannot install git bash alone; to install it, we need to go to git-scm.com, the official website of git.
- On the git website, download the latest identified version for Windows.
- 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.
- Click Next until you get to the Install button; restart your computer after the installation.
- To configure Hyper to use git bash, you need to visit this GitHub link and copy the entire code in the hyper.js file.
- Click the Options button on the top-left of your Hyper terminal; hover over the Edit option and select Preferences.
- The program will open a configuration file; if it is not blank, press Ctrl + A to select all and clear it.
- Paste the configuration you copied from the GitHub repo and save the file.
- You’ll notice Hyper updating its configuration; close Hyper and open it again.
- 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:
|1||ls||It lists the directories in your current location.||ls|
|2||touch||It’s used to create a new file||touch sample.txt|
|3||mkdir||It’s used to create a new directory in the current location||mkdir New Folder|
|4||cd||It’s used to change your current working directory to a specified location||cd Users\Stephen\Desktop|
|5||..||It’s used to go back to the immediate parent directory||..|
|6||exit||This command will close a terminal window, end the execution of a shell script, or log you out of an SSH remote access session.||exit|
|7||clear||It is used to clear all previous commands and output on the terminal window||clear|
|8||man||This is used to show instructions on what a command does; you type man and put the command name in front||man touch|
|9||pwd||It is used to print the working directory you’re currently on||pwd|
|10||locate||It used to search for a file or directory||locate sample.txt|
Read More: What is DevOps?