Git Bash
change directory
command line
tutorial
beginners guide

How to change folder with git bash?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

In Git Bash, changing folders works the same way it does in a normal Unix shell: you use the cd command. The only part that sometimes confuses Windows users is the path format, because Git Bash translates Windows drives into Unix-style paths such as /c/Users/markqian.

Basic cd Usage

To move into another folder, type cd followed by the target path:

bash
cd /c/Users/markqian/Documents/project

You can check where you are with pwd:

bash
pwd

And list the contents of the current folder with ls:

bash
ls

Those three commands are usually enough for everyday navigation.

Windows Paths in Git Bash

Git Bash does not usually want raw Windows path syntax like C:\Users\markqian. Instead, it maps drives like this:

  • 'C:\ becomes /c/'
  • 'D:\ becomes /d/'

So if Explorer shows:

text
C:\Users\markqian\Desktop\repo

the Git Bash path is:

bash
cd /c/Users/markqian/Desktop/repo

Once you get used to that conversion, navigation becomes straightforward.

Relative Paths

You do not always need the full absolute path. If the target folder is inside your current folder, a relative path is shorter:

bash
cd src
cd components

To go up one folder:

bash
cd ..

To go up two levels:

bash
cd ../..

This is especially useful when moving around inside a repository.

Folders with Spaces

If the folder name contains spaces, wrap the path in quotes:

bash
cd "/c/Users/markqian/My Projects/demo app"

You can also escape spaces with backslashes:

bash
cd /c/Users/markqian/My\ Projects/demo\ app

Quotes are usually easier to read, especially for beginners.

Useful Navigation Shortcuts

Git Bash supports a few common shell shortcuts:

  • 'cd ~ goes to your home directory'
  • 'cd - returns to the previous directory'
  • pressing Tab autocompletes folder names

Example:

bash
cd ~
cd /c/Users/markqian/Documents
cd -

That last command is handy when switching back and forth between two folders.

Finding the Path You Actually Need

If you are not sure what to type after cd, a practical trick is to navigate to the folder in Windows Explorer first and then translate the path into Git Bash style. For example, if Explorer shows D:\work\demo-repo, the matching Git Bash command is:

bash
cd /d/work/demo-repo

This is often easier for beginners than trying to guess the shell path from memory.

Typical Git Workflow Example

Here is a short real-world session:

bash
1pwd
2cd /c/Users/markqian/Documents
3ls
4cd my-repository
5git status

The important point is that Git commands do not change folders for you. You must cd into the repository before commands like git status, git add, or git pull operate on the project you expect.

Common Pitfalls

The most common mistake is using Windows backslash paths directly. In Git Bash, /c/Users/... is usually safer than C:\Users\....

Another frequent issue is forgetting quotes around paths with spaces. That makes Bash interpret each word as a separate argument.

Some users also expect Git Bash to change into the repository automatically when they open the terminal. It usually starts in the home directory instead, so checking with pwd avoids confusion.

Finally, cd only changes location in the current shell session. It does not move files and it does not affect Windows Explorer.

Summary

  • Use cd to change folders in Git Bash.
  • Git Bash maps Windows drives like C:\ to paths such as /c/.
  • Use relative paths like cd .. when moving around nearby folders.
  • Quote paths that contain spaces.
  • Check your current location with pwd before running Git commands.

Course illustration
Course illustration

All Rights Reserved.