Is there a way to change the root (/) directory of git bash on windows.
By default it is set to the installation folder. Setting it to c:\ instead would save needing to type the drive letter e.g. /c/some/path on all absolute paths.
Is there a way to change the root (/) directory of git bash on windows.
By default it is set to the installation folder. Setting it to c:\ instead would save needing to type the drive letter e.g. /c/some/path on all absolute paths.
echo 'cd /c/' >> ~/.bashrc
Automatically go to /c/ directory when opening bash cli.
What you can do is mount some windows paths to a root-based msys2 paths:
mount c:/src /src
Then you can access C:/src/... as /src/...
If you installed git right, then two commands will appear in the file explorer menu when you call it with right-click. You will see nice color-full icons for both two commands: - Git GUI Here - Git bash Here took me 3 days... so you can run both from anywhere.. just go there and run from there!!
What worked for me (Windows 10) was to edit the shortcut.
Previously the Target was "C:\Program Files\Git\git-bash.exe" --cd-to-home Start in: was my homedir
I changed Start in to be C: and removed --cd-to-home
Now bash starts in /c
In your .bashrc
file :
function cd {
cd "/c/${1}"
}
I would think this should work for all cases. This would limit you to C Drive absolute paths though.
I fixed it by searching the bash.rc
file in my file explorer, opening the file with code and replacing everything with cd /C:\Users\windows/
change the git bash lnk's target , remove the --cd-to-home
then add the path into start in:
here is mine enter image description here
then open git bash to test
© 2022 - 2024 — McMap. All rights reserved.
"C:\D\"
and"D:\"
correspond to same/D/
– Particiaparticipant