How to change folder with git bash?
Here are the steps I followed:
In bash, check in which directory you are by using the command:
$ pwd
copy the URL of the directory you want to go like after using the first command (
PWD
) I got:$ /c/Users/yourUsername
Now I want to change this to the directory of
c
drive and folderMyPictures
. To do that, I will go the directory ofMyPictures
, copy the URL, and paste it in the Git bash. However, before that:C:\MyPicture
becomes$ cd /C/MyPicture
(backslashes are replaced with slashes)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"
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.
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
.
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..."