30

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
2
  • 8
    Well, you can use pwd -W, but it uses forward slash, this is probably the closest you'll get. You can always do cmd.exe /c cd. Commented Jun 30, 2017 at 8:46
  • 1
    Thanks @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. Commented Jun 30, 2017 at 9:27

1 Answer 1

50

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
answered Feb 13, 2018 at 23:09
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks @vestlen, single slash cmd /c cd also works. Why double slash ?
@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.
To turn the slashes to back-slashed with pwd -W, just use: pwd -W | sed 's,/,\,円g'

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.