In Git for windows "git bash", how to "print working directory" in Windows path format that is usable by cmd and Windows explorer?
28,179
In Git Bash:
$ cmd //c cd
C:\Program Files\Git
Note the double slash. And for forward slashes, as mentioned in the comments:
$ pwd -W
C:/Program Files/Git
Related videos on Youtube
Author by
yhd.leung
Updated on February 14, 2020Comments
-
yhd.leung about 4 years
When using Git for Windows "git bash" on Windows, how to conveniently print the working directory in Windows path representation, e.g.
D:\foo\bar
similar to using 'pwd' to get the Unix representation
/d/foo/bar/
such that the path can be read by Windows explorer and cmd console?
-
Lasse V. Karlsen almost 7 yearsWell, you can use
pwd -W
, but it uses forward slash, this is probably the closest you'll get. You can always docmd.exe /c cd
. -
yhd.leung almost 7 yearsThanks @Lasse,
pwd -W
is fit for my use-cases on Windows explorer and cmd console. I didn't realize they accept forward slash too. I really want to take your comment as answer.
-
-
yhd.leung about 6 yearsThanks @vestlen, single slash
cmd /c cd
also works. Why double slash ? -
vestlen almost 6 years@yhd.leung On my box at least, using the single slash leaves you sitting in the cmd shell. Using the double slash prints the directory and then exits cmd, returning you to the bash shell.
-
Kanhaiya over 2 yearsTo turn the slashes to back-slashed with
pwd -W
, just use:pwd -W | sed 's,/,\\,g'