48

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 /).

Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
Joshua Meyers
  • 597
  • 1
  • 4
  • 4
  • 9
    Try running `mount` in the the bash shell. – DavidPostill Mar 26 '17 at 17:54
  • Read https://danlimerick.wordpress.com/2011/07/11/git-for-windows-tip-setting-home-and-the-startup-directory/ or http://shawnhymel.com/576/quick-tip-changing-default-directory-of-git-bash/ – Lazy Badger Mar 26 '17 at 19:03
  • 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 05: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 05:08
  • 2
    Again: http://www.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 08:39

6 Answers6

76

In Git Bash, open Windows Explorer with this command:

explorer .

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

Gary Barrett
  • 4,692
  • 3
  • 19
  • 23
12

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.)

wisbucky
  • 2,928
  • 31
  • 29
  • 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 02:59
3

Thank @GaryBarrett for his/her nice hint.

In git-bash:

cd /bin
start .
Mir-Ismaili
  • 283
  • 1
  • 2
  • 11
2

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

if you using Far Manager it's possible to find an application/file by pressing Alt-F7 then bash.exe in the search field. Second, need to select the Select search area parameter to In PATH Foldersenter image description here.

This will be helpful if you accidentally install more bash installations than one.

-1

if on my computer with windows it is here: C:\Program Files\Git\mingw64\bin

or this is the default location C:\Program Files\Git\mingw64\

gUfriL
  • 1
  • That doesn't make any sense unless you've modified the install. If you haven't modified your install / isn't where you think it is. – music2myear Nov 20 '21 at 04:14