How to Change Drive in Git Bash

Naila Saad Siddiqui Feb 15, 2024
  1. Git Bash
  2. Git Commands to Change the Drive
How to Change Drive in Git Bash

This short article will discuss how we can use Git Bash to have a Unix-style command line environment in the Windows operating system and run multiple commands on this terminal.

Git Bash

Git is a collection of command-line utilities created to run in a Unix-style command-line environment. Unix command line terminals are found in many contemporary operating systems, including Linux and macOS.

As a result, when using Git, Linux and macOS are complementary operating systems. Instead, Microsoft Windows uses the non-Unix terminal environment known as Windows Command Prompt.

For Microsoft Windows environments, Git Bash is a program that offers an emulation layer for the Git command line interface.

The abbreviation BASH stands for Bourne Again Shell. An operating system can be accessed through written commands using a shell or a terminal program.

The popular default shell for Linux and macOS is Bash.

Git Bash Operations

The operations of Git Bash are identical to those of a typical Bash session. Reviewing the fundamentals of Bash usage will be beneficial.

The focus of this document is on Git commands to change the directory.

Git Commands to Change the Drive

Many commands are used in Git Bash, which is the same as we use in Unix Bash but are different from the Windows command-line interface.

  1. For getting the current directory, we use the command pwd.
  2. We use the ls command to list the contents of the current working directory, which is different from the dir command in Windows CLI.
  3. To change the directory to another, we use the cd command. Windows and Bash have the same cd command for changing the current working directory to any other folder in the hierarchy.

For example, if we need to change the current working directory to drive F, we will use the cd command like this:

cd Command to Change Working Directory in Git Bash

In the same way, we can provide the complete path of the directory we wish to work on. Let’s look at another example in which we navigate to another folder in the c drive.

cd Command With Directory Path in Git Bash

Now, we can check the current working directory through the pwd command and then list the folders and files in this directory.

ls Command in Git Bash

This way, Git Bash is used and provides us with the Unix-style command line terminal environment.

Related Article - Git Bash

Related Article - Git Directory