Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change folder with git bash?

Tags:

git

git-bash

The command is:

cd  /c/project/

Tip:
Use the pwd command to see which path you are currently in, handy when you did a right-click "Git Bash here..."


Go to the directory manually and do right click → Select 'Git bash' option.

Git bash terminal automatically opens with the intended directory. For example, go to your project folder. While in the folder, right click and select the option and 'Git bash'. It will open automatically with /c/project.


Here are the steps I followed:

  1. In bash, check in which directory you are by using the command:

    $ pwd
    
  2. copy the URL of the directory you want to go like after using the first command (PWD) I got:

    $  /c/Users/yourUsername
    
  3. Now I want to change this to the directory of c drive and folder MyPictures. To do that, I will go the directory of MyPictures, copy the URL, and paste it in the Git bash. However, before that:

     syntax changes in bash

    C:\MyPicture becomes $ cd /C/MyPicture (backslashes are replaced with slashes)

  4. if the folder name is having some spaces like (my program) then you need to enclose it in double quotes like:

    $ cd "C:\Program Files"
    
  5. Remember to change directory you just need to copy the requiredUrl and paste that in bash with double-quotes like:

    cd "required URL"
    

Note: URL required with slashes.


How to change folders in Git Bash

As Bob mentioned, you can change directories with cd:

cd /c/project

If you have a Windows path with backslashes, enclose the path in double quotes:

cd "C:\project"

Tips

  • You can check the current folder with pwd.

  • If the path contains spaces, you will need to use quotation marks. (cd "C:/Program Files")

  • On Windows, you change the default starting directory for Git Bash.

    • Right click git-bash.exe, select Properties, open Shortcuts, and change Start in: to your most commonly used folder. (screenshot)
  • The cd command can be memorized as "change directory".

See also

  • ss64 - Bash CD command
  • Stack Overflow - Forward slash vs backward slash for file path in git bash

pwd: to check where you are (If necessary)

cd: change directory

In your case if I understand you, you need:

cd c/project