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.
- For getting the current directory, we use the command
pwd
. - We use the
ls
command to list the contents of the current working directory, which is different from thedir
command in Windows CLI. - To change the directory to another, we use the
cd
command. Windows and Bash have the samecd
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:
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.
Now, we can check the current working directory through the pwd
command and then list the folders and files in this directory.
This way, Git Bash is used and provides us with the Unix-style command line terminal environment.
Related Article - Git Bash
- How to Open Git Bash on Mac
- How to Configure Git Bash With Visual Studio Code
- How to Copy and Paste in Git Bash