22

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?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
B Johnson
  • 2,408
  • 3
  • 20
  • 32
  • Did u try the same in "cmd" (dos-prompt) ? I think it will work there – trans1st0r May 03 '13 at 11:31
  • @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. – B Johnson May 03 '13 at 21:14
  • Have you checked http://stackoverflow.com/q/11519659/1983854 ? Also, does `ls /mnt/sdcard/` work? To see if it detects the path properly. – fedorqui Jun 17 '13 at 11:16
  • 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! – Stephen Hosking Jul 11 '20 at 03:22

2 Answers2

40

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)

Community
  • 1
  • 1
Richard Hansen
  • 51,690
  • 20
  • 90
  • 97
9

adb push myfile //mnt/sdcard

linux isn't picky about duplicate /s

Jayen
  • 5,653
  • 2
  • 44
  • 65