Published on: December 16, 2024
4 min read
Learn about Git Bash, how it works, how to install it, and the main commands you need to know.
Git commands allow developers to manage different versions of code and collaborate as a team. If you're in a Windows environment, you may have heard of Git Bash, a Bash terminal emulator that includes a Windows-friendly version of Git. Discover everything you need to know about installing Git Bash in this guide.
Git Bash is an application that you can install on Windows operating systems using Git for Windows. This application acts as an emulator to use the Git version control tool on a Bash command terminal.
Bash is an acronym for Bourne Again SHell. SHell refers to the command terminal application of an operating system (OS). Bourne Again SHell is actually an upgraded version of Bourne SHell (also referred to as shell sh), the command line interface for UNIX developed by Stephen Bourne in 1977.
Bash is the default shell for Linux and MacOS operating systems. With Git Bash, Windows users can install Bash, run Bash commands and use Git commands.
To download Git Bash, it is necessary to install Git for Windows. To do this, go to the official Git for Windows website and click "Download" to install the full Git package. When the download is complete, open the .exe file and begin the installation.
To install Git Bash on Windows, please follow these step-by-step instructions:
First of all, the pwd
(Print Working Directory) command allows you to view the absolute path. This means that it displays the path of the folder we are in at the time of typing the command.
Remember: When you open the Git Bash terminal, you are in a folder on your computer. Usually, this is the folder with your username.
The ls
command gives access to the list of files present in the current folder. You can also add options to the ls
command with a dash -
. For example, the -l
option after ls
lists the contents of a folder with more information about each file.
Bash also has a cd
(Change Directory) command to move around your computer. To indicate the directory you want to go to, please specify the relative or absolute path after cd
. The relative path is the location relative to the current directory while the absolute path is its location relative to the root folder.
Using Git Bash with GitLab is like using the terminal emulator with another source code management platform. In order to push and retrieve your changes from GitLab, add the URL of your GitLab remote repository with the command: git remote add origin <repository_url>
.
If your project is private, Git Bash asks you to authenticate yourself. Enter your credentials when the terminal requests your username and password. If you're having trouble logging in, check your authorization settings directly in GitLab.
Then use the basic Git commands like git clone
, git commit
, git push
, git branch
, as well as git checkout
, to name a few. To learn more, visit our Git Cheat Sheet.
Are Git Bash and GitLab compatible?
Yes. Using Git Bash with GitLab is similar to working with another source code management platform. Be sure to set up GitLab as a remote repository and authenticate yourself during the initial setup.
Why use Git Bash?
Git Bash acts as a terminal emulator to use the Git and Bash commands in a Windows environment.
What's the point of a shell?
Using a shell allows you to automate tasks through scripts, effectively control your computer and benefit from direct access to system functions.