HOWTO · Bash

How to Change Directory With Git Bash

Change directories in Git Bash with cd. Check your location with pwd, navigate with relative or Windows drive paths, quote folder names with spaces, and use Tab completion.

On this page

In Git Bash, use cd followed by a folder path to change directories, and run pwd to see your current location. Paths can be absolute or relative to the directory you are in.

Check the Current Directory and Change It

Run pwd before navigating if you need to confirm where you are. This self-contained example creates a temporary project folder, enters it, and prints its final folder name. The supplied runtime result is Projects, and the command exits with code 0.

demo_dir=$(mktemp -d)
trap 'cd /; rm -rf "$demo_dir"' EXIT
mkdir -p "$demo_dir/Projects"
cd "$demo_dir/Projects"
printf '%s\n' "${PWD##*/}"
Projects

In your own shell, use cd with the destination, then run pwd to confirm it. The result depends on your actual directory and target.

Change to a Specific Directory in Git Bash

Use an absolute path when you want to go directly to a known location. The tilde (~) expands to your home directory when it is unquoted, so cd ~/Desktop/Projects enters that folder under your home directory. To move home itself, use cd or cd ~.

For a folder whose name contains spaces, quote the path. Use cd "$HOME/Desktop/My Projects"; $HOME expands even inside double quotes, while a quoted ~ may remain a literal character.

Use Relative Paths to Navigate

A relative path starts from the current directory. Use cd Projects to enter a child folder named Projects, cd .. to move to its parent, or cd ../../.. to move up three levels. Each .. represents one parent directory. You can chain navigation, such as cd .. && cd AnotherFolder, when AnotherFolder is inside the parent directory.

Handle Spaces and Windows Drive Paths

In Git Bash, use a slash-style path for a Windows drive: cd /d/Projects enters the Projects folder on drive D, if it exists. The /d/ prefix corresponds to the Windows D:\ drive root. Avoid writing D:\Projects as an unquoted Bash argument: the backslash can act as an escape and be removed. Quote paths with spaces, such as cd "/d/Project Files", so the shell treats the path as one argument.

Use Tab Completion

Type part of a folder name after cd and press Tab. If the name uniquely matches a folder, Git Bash completes it. If more than one name matches, press Tab again to list the available matches, then type enough characters to choose the intended folder. Completion can save typing, but verify the completed path before pressing Enter.

Troubleshoot Common Path Errors

If cd reports “No such file or directory,” run pwd to check the starting location. Confirm the destination spelling and capitalization, whether the folder exists there, and that spaces are quoted. For a Windows drive, check that you used Git Bash path notation such as /d/Projects. A relative path is resolved from the current directory, so use an absolute path when the starting location is uncertain.