30

When I open Git Bash on Windows 7, the default directory is /. It has *nix-style subdirectories, and cd .. doesn't change the directory. Where is this directory on my Windows machine?

The directory C:\Program Files\Git\ has similar contents, except that / has a proc subdirectory, and C:\Program Files\Git\ doesn't.

I put dir /s /a git-bash.exe in cmd.exe, and it only came up with the git-bash.exe in C:\Program Files\Git, no other one (such as the one in /).

5
  • 8
    Try running mount in the the bash shell. – DavidPostill Mar 26 '17 at 17:54
  • 1
    @LazyBadger OK so according to Git Bash Properties (I right-clicked on Git Bash), it starts in C:\Program Files\Git\ . This still doesn't answer why / has a proc subdirectory and C:\Program Files\Git\ doesn't. Do you know? – Joshua Meyers Mar 27 '17 at 5:05
  • @DavidPostill Thanks, this also corroborates this. mount gives the line: C:/Program Files/Git on / type ntfs (binary,noacl,auto). But why does / have a proc subdirectory that C:\Program FIles\Git\ doesn't have then? – Joshua Meyers Mar 27 '17 at 5:08
  • 2
    Again: tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html "/proc is very special in that it is also a virtual filesystem. It's sometimes referred to as a process information pseudo-file system. It doesn't contain 'real' files but runtime system information (e.g. system memory, devices mounted, hardware configuration, etc)." – Lazy Badger Mar 27 '17 at 8:39
44

In Git Bash, open Windows Explorer with this command:

explorer .

You will then see your current directory in the explorer address bar

1
  • 5
    excellent answer : simple and actually works for any folder. With this I discovered that /tmp was mounted for c:/users/[my winuser]/[local app data folder]/temp – Pacopaco Jun 12 '19 at 7:48
6

You can run cmd from the current directory in Git Bash. That will start a windows cmd shell, which will show the windows path in the command prompt. Then type exit to return to Git Bash.

For example:

$ cmd
Microsoft Windows ...

C:\Program Files\Git>

(This is also a quick way to convert unix path to windows path.)

1
  • Do you have advice on the opposite conversion? I.e. I am having trouble navigating to some of the standard Windows paths on the Linux prompt (e.g. how do I cd to C:\Program Files ?) – Ben Farmer Oct 29 '20 at 2:59
0

cd / && pwd -W | sed 's/\//\\/g'

$ echo "$(cd / && pwd -W | sed 's/\//\\/g')"
C:\Users\EXAMPLEUSER\Documents\PortableGit

Explanation:

Changing directory to root directory '/' will take you to where git was installed. The conventional "$PWD" variable won't provide much help as it says '/' too. To get the true working directory, the command pwd followed by the -W argument is required

-W print the Win32 value of the physical directory

This alone will print the correct and full directory, however it uses the Unix '/' separator between directories which Windows may not use system-wide, so the sed command edits the '/'s to '\'s

0

Thank @GaryBarrett for his/her nice hint.

In git-bash:

cd /bin
start .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.