2

Usually I start it up and I'm located in my windows user directory. I can see all my project folders with a quick ll. The last few times I've used it, though, I seem to be stuck in some pseudo linux environment. pwd says I'm at /. And if I cd .. I go nowhere.

And none of the folders look like I'm on windows. What is going on here?

Buttle@butkus MINGW64 /
$ ll
total 3412
drwxr-xr-x 1 Buttle 197609       0 Oct 29 14:13 bin/
drwxr-xr-x 1 Buttle 197609       0 Oct 29 14:13 cmd/
drwxr-xr-x 1 Buttle 197609       0 Oct 29 14:13 dev/
drwxr-xr-x 1 Buttle 197609       0 Oct 29 14:13 etc/
-rwxr-xr-x 1 Buttle 197609  140800 Oct 19 20:06 git-bash.exe*
-rwxr-xr-x 1 Buttle 197609  140288 Oct 19 20:06 git-cmd.exe*
drwxr-xr-x 1 Buttle 197609       0 Oct 29 14:13 mingw64/
dr-xr-xr-x 9 Buttle 197609       0 Feb  2 01:35 proc/
-rw-r--r-- 1 Buttle 197609   57831 Oct 19 20:17 ReleaseNotes.html
drwxr-xr-x 1 Buttle 197609       0 Feb  2 01:35 tmp/
-rw-r--r-- 1 Buttle 197609  968936 Oct 29 14:13 unins000.dat
-rwxr-xr-x 1 Buttle 197609 1300779 Oct 29 14:09 unins000.exe*
drwxr-xr-x 1 Buttle 197609       0 Oct 29 14:13 usr/

Buttle@butkus MINGW64 /
$

As stated above, I'm using Windows. But the reason I'm confused is that I used to start out inside my regular Windows filesystem's user directory, from which I could just cd into the project directory. Now I don't know where I am. pwd says I'm in the root directory but I cannot find any of my Windows filesystem or any of my git projects. Git UI for Windows (again, on Windows) is working fine but I prefer the command line.

Edit: Notes on solutions

Thanks to @Tim Biegeleisen for his answer. I also found this solution: https://stackoverflow.com/a/10652224/631764

I edited the original Git Bash shortcut in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Git and removed --cd-to-home from the start up options. Then I changed the "Start in" section to go to my projects directory, so that it now looks like this: %HOMEDRIVE%%HOMEPATH%\Projects

I had to delete my Taskbar icon - it had somehow gotten disconnected from its roots - and then after pinning the Git Bash shortcut to my taskbar, everything worked as expected. If it becomes disconnected again, I will just delete and restore the Taskbar pin again.

Community
  • 1
  • 1
Buttle Butkus
  • 9,206
  • 13
  • 79
  • 120
  • 1
    Vaguely Unix-like, yes, but that's hardly "some kind of Linux". Linux is "some kind of Unix", not the other way around. – tripleee Feb 02 '16 at 09:59
  • Can you expand on what you're using? This looks like the git-for-windows SDK / msys2. All provide an environment to *nix programs to operate in, and that includes a ~virtual filesystem which you're seeing here. Normally some paths are mapped to real locations on your NTFS filesystem, but I only really know cygwin (which maps at /cygdrive). If the paths are somehow inaccessible, it's likely it will just fallback to the root for the default working directory. – tne Feb 02 '16 at 10:07
  • This is what it's supposed to look like. Those directories you see will be under wherever you installed Git Bash to. – M.M Feb 02 '16 at 10:16
  • @M.M Well that's strange that it's supposed to look like a black box from which I cannot escape, in which no repositories may be found, because it never looked like that until about a week ago. It used to put me in my Windows filesystem user directory when I started it up. Tim Biegeleisen answered got me out of this jail, but I still wonder just where I am when I launch the Git bash. – Buttle Butkus Feb 03 '16 at 02:18
  • The `pwd` command shows you the full (Unix-like) path of the current directory. `cd` with no arguments should take you to your home directory. `echo $HOME` or `echo ~` will show you the full path of your home directory. It sounds like git bash may have lost track of your home directory. It sets up something that looks like a Unix directory structure, with `/` as the root. That *should* map to some specific Windows directory. – Keith Thompson Feb 03 '16 at 02:33
  • @ButtleButkus It simulates a unix-like directory structure so that common tools work which assume that structure (e.g. bash looks in /etc for stuff). Your other drives will be mounted under their drive letter , e.g. `cd /c` . Previously you would have been under `/c` somewhere but not noticed. – M.M Feb 03 '16 at 02:36
  • @M.M yes I didn't notice anything Unix-y in my directory structure before. Of course I was surprised and happy I could use `ll` and other familiar command line tools. I guess I could even add my own aliases to `etc/bash.bashrc`. But I wonder if I am actually traversing directories in my Windows computer or if it is just simulated? It seems like the place I'm starting now, with the Unix-y stuff, is completely disconnected from my simulated Windows directories in this git bash interface. – Buttle Butkus Feb 03 '16 at 02:59
  • Yes, they are real directories under your Git Bash installation somewhere – M.M Feb 03 '16 at 03:02
  • @M.M but yet I cannot `cd ..` in my git bash interface to descend out of them. That's my confusion. It's like I'm stuck there. Except `cd /C` does take me out to my regular windows C drive. – Buttle Butkus Feb 03 '16 at 03:04
  • Yes, as I said earlier the purpose is to simulate a unix-like structure. You can't `cd ..` from root in that either. Read up on *mounting* in filesystems, that path is mounted on `/`. – M.M Feb 03 '16 at 03:05

1 Answers1

6

From what I can, this is normal behavior for the Git Bash tool. I was able to reproduce the Linux-esque directory listing obtained by typing ll. The reason pwd is returning / is because your bash is starting up in the root directory, which defaults to the location where Git was installed on your machine (C:\Program Files\Git on my computer). When you type cd .. you can't go anywhere, because you are already in the root position in the directory tree.

To change to your user directory you can try the following:

tbiegeleisen@niihau MINGW64 /
$ cd C:

tbiegeleisen@niihau MINGW64 /c
$ cd Users/tbiegeleisen/

I think the only difference in behavior you are seeing is that the Git bash may have someone "forgotten" in which directory it should start. If you use the two commands I gave above, you can easily navigate back to the directory containing your source code.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • Thank you. I don't know why it didn't occur to me to type the full path to where I was going. But I still find it strange that I seemed to be inside of a jailed shell. It does seem like it "forgot" where it should start. I should like to remind it. Do you have any idea how to do that? – Buttle Butkus Feb 03 '16 at 02:21
  • 2
    Let me research this and get back to you. – Tim Biegeleisen Feb 03 '16 at 02:29