In this article, we will learn about changing the directory in Bash.
directory is used to refer to a folder. Because you are constantly moving between different folders while working in Bash and using the Git version control system, it is essential to frequently change the directory that you are working in.
There are two different approaches to making changes to the directory.
- Using Git Bash commands directly
- Git Bash is run in the selected folder.
Example of running Git Bash in selected folder:
Change Directory in Bash
The following example will move the working directory to the
zoom folder from its existing location at
/c/Users/DELL/Documents. To travel to the directory corresponding to our intended destination, we have used the term
cd in the command line, followed by the directory’s name, which works.
This takes us to a new directory within the
zoom folder. We discovered by executing the
ls command that it consists of a text file named
Another option is to use the
cd - instruction, which allows you to go back to the directory or folder you were in. This command would make it easy for you to navigate back to the correct directory if you navigated to the incorrect one by accident.
For example, to get back to the
Documents directory after leaving it, we used the command
cd - rather than inputting the command that included the whole path. This allowed us to quickly get back to the working directory.
Once this command has been carried out, the operating system will navigate us to the
Documents folder, as demonstrated below.