Changing the root directory (/) of git bash
Solution 1
echo 'cd /c/' >> ~/.bashrc
Automatically go to /c/ directory when opening bash cli.
Solution 2
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!!
Solution 3
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/...
Solution 4
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.
Solution 5
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
Related videos on Youtube
79E09796
Updated on July 09, 2022Comments
-
79E09796 almost 2 years
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.
-
79E09796 over 7 yearsThis is a good workaround, it's limited to mapping individual directories in Cygwin, but something that works in git bash for all directories might not be possible.
-
max630 almost 7 yearsRight, mounting to root does not work. But I did not propose it.
-
EverPresent over 6 yearsWhy was this downvoted? I upvoted it. It works great for me and is way better than copying folders into the root C: drive like the accepted answer suggests.
-
79E09796 about 6 yearsIf it helps your use case it's great, I wouldn't downvote it. However it doesn't allow unix style absolute paths for the c drive, so can't accept it as the answer either.