【问题标题】:How do I pass an absolute path to the adb command via git bash for windows?如何通过 Windows 的 git bash 将绝对路径传递给 adb 命令?
【发布时间】:2013-11-12 13:34:38
【问题描述】:

我正在尝试使用 git bash (msysgit) 将 unix 样式路径传递给 Android adb 命令,但 shell 错误地解释了我的路径。这是我迄今为止尝试过的:

$ 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

这样做的正确方法是什么?

【问题讨论】:

  • 你在“cmd”(dos-prompt)中尝试过同样的方法吗?我认为它会在那里工作
  • @DevJyotiBehera 是的,我确实在 windows cmd 提示符下尝试过,它确实有效,但我试图弄清楚为什么它不适用于 msysgit。我想了解路径和引用如何在这里工作。
  • 你检查过stackoverflow.com/q/11519659/1983854 吗?另外,ls /mnt/sdcard/ 有效吗?看看它是否正确检测到路径。
  • 这里有同样的问题。 Gitbash、adb 和推/拉请求。 gitbash 中的所有内容似乎都按照标准 bash 工作。奇怪的是,我的系统甚至通过在预期路径前加上 C:/Program Files/Git 来复制您的问题。下面的两种解决方案都对我有用,所以我正在运行一个更简单的解决方案,即。 adb push myfile //mnt/sdcard。救命稻草!

标签: windows git bash adb msys


【解决方案1】:

根据this answer,MSYS shell 正在根据these rules 修改文件名。根据修改规则,以下内容应该适合您:

adb push myfile '//mnt\sdcard\'

(用两个斜杠替换第一个斜杠,用反斜杠替换所有剩余的斜杠)

【讨论】:

  • 我能够使用所有正斜杠 (/) 来做到这一点
  • 你拯救了我的一天。谢谢。
  • 我不得不使用"//mnt\/sdcard\/"
【解决方案2】:

adb push myfile //mnt/sdcard

linux 对重复的 /s 并不挑剔

【讨论】:

    猜你喜欢
    • 2016-04-26
    • 1970-01-01
    • 2018-02-14
    • 2020-05-14
    • 1970-01-01
    • 2023-03-07
    • 2018-02-13
    • 2023-04-05
    • 2010-10-08
    相关资源
    最近更新 更多