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?
asked Jun 30, 2017 at 8:44
yhd.leung
1,6322 gold badges25 silver badges35 bronze badges
1 Answer 1
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
Sign up to request clarification or add additional context in comments.
3 Comments
yhd.leung
Thanks @vestlen, single slash
cmd /c cd also works. Why double slash ?vestlen
@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.
Tilman Vogel
To turn the slashes to back-slashed with
pwd -W, just use: pwd -W | sed 's,/,\,円g'lang-bash
pwd -W, but it uses forward slash, this is probably the closest you'll get. You can always docmd.exe /c cd.pwd -Wis 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.