How do I pass an absolute path to the adb command via git bash for windows?
Asked Answered
A

2

23

I'm trying to pass a unix style path to the Android adb command using a git bash (msysgit) but the shell is interpreting my path incorrectly. This is what I've tried so far:

$ adb push myfile /mnt/sdcard/
failed to copy 'myfile' to 'C:/Program Files (x86)/Git/mnt/sdcard/': No such file or directory

$ adb push myfile "/mnt/sdcard/"
failed to copy 'myfile' to 'C:/Program Files (x86)/Git/mnt/sdcard/': No such file or directory

$ adb push myfile '/mnt/sdcard/'
failed to copy 'myfile' to 'C:/Program Files (x86)/Git/mnt/sdcard/': No such file or directory

What is the correct way to do this?

Agist answered 2/5, 2013 at 18:17 Comment(4)
Did u try the same in "cmd" (dos-prompt) ? I think it will work thereFratricide
@DevJyotiBehera Yes, I did try it with the windows cmd prompt, and it does work, but I was trying to figure out why it was not working with msysgit. I want to understand how paths and quoting work here.Agist
Have you checked https://mcmap.net/q/584804/-android-adb-exe-pull-mnt-sdcard-somefile-txt-not-working/1983854 ? Also, does ls /mnt/sdcard/ work? To see if it detects the path properly.Mazda
Identical problem here. Gitbash, adb, and push/pull requests. Everything in gitbash seems to work as per standard bash. Curiously, my system even duplicated your problem by prefixing the intended path with C:/Program Files/Git. Both solutions below worked for me, so I'm running withe simpler one, ie. adb push myfile //mnt/sdcard. Lifesaver!Godding
R
41

According to this answer, the MSYS shell is mangling the file name according to these rules. According to the mangling rules, the following should work for you:

adb push myfile '//mnt\sdcard\'

(replace the first slash with two slashes and all remaining slashes with a backslash)

Resurgent answered 17/6, 2013 at 1:34 Comment(3)
i was able to do it with all forward-slashes (/)Alpestrine
U saved my day. Thx.Demonize
I had to use "//mnt\/sdcard\/"Naples
A
9

adb push myfile //mnt/sdcard

linux isn't picky about duplicate /s

Alpestrine answered 12/11, 2013 at 5:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.