简体   繁体   English

mv:无法将“water.txt”移动到“/liquid”:Windows 中的权限被拒绝 [Git bash]

[英]mv: cannot move 'water.txt' to '/liquid': Permission denied [Git bash] in Windows

I have created two directories in desktop as solid and liquid.Initially liquid doesn't have any files but solid has two files as rock.txt and water.txt.I tried to move water.txt to liquid but it throws and error.How can i fix this?我在桌面上创建了两个目录,分别是固体和液体。最初液体没有任何文件,但固体有两个文件,分别是 rock.txt 和 water.txt。我试图将 water.txt 移动到液体,但它会抛出错误。如何我可以解决这个问题吗?

''' $ mv water.txt /liquid ''' $ mv water.txt /液体

mv: cannot move 'water.txt' to '/liquid': Permission denied mv:无法将“water.txt”移动到“/liquid”:权限被拒绝

''' '''

Following your steps, your Desktop/ folder should look like this:按照您的步骤,您的Desktop/文件夹应如下所示:

├── liquid
├── solid
│   ├── rock.txt
│   └── water.txt

There are two major issues causing this behaviour.有两个主要问题导致了这种行为。

  1. Assuming you are currently in solid/ directory, you need to reference the relative path of the liquid/ directory.假设你当前在solid/目录下,需要引用liquid/目录的相对路径。 Since it resides in the same level as the parent directory of water.txt file, you need to use .. (double dots) according to the unix convention.由于它与 water.txt 文件的父目录位于同一级别,因此您需要根据 unix 约定使用.. (双点)。 ( for more context read dot definition ) (更多上下文阅读点定义

     # currently in solid directory $ pwd /c/Users/USER/Desktop/solid # move file to liquid directory ✔ $ mv water.txt../liquid/
  2. In Unix based systems, directories are typically represented by it's name followed by a front slash / , not the other way around.在基于 Unix 的系统中,目录通常由其名称后跟前斜杠/表示,而不是相反。 Ex: music/ .例如: music/ . In fact, putting / in front of a directory name is prohibited in both Windows and Linux .事实上,在 Windows 和 Linux 中都禁止在目录名称前放置/ Moreover, when the two arguments are in the same directory, mv command interprets it as a rename operation on the first argument.此外,当两个 arguments 在同一目录下时, mv命令将其解释为对第一个参数的重命名操作

     # git bash thinks /liquid is a file in current directory; rename operation fails ❌ $ mv water.txt /liquid # git bash thinks liquid to be in upper level; no renaming; move succeeds ✔ $ mv water.txt../liquid/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows中的Git Bash无法正常工作(连续权限被拒绝错误) - Git Bash in Windows not working (continuous permission denied error) 使用 git bash 时权限被拒绝 - Permission denied when using git bash 如何解决 git bash 上的“权限被拒绝”错误? - How to solve a "permission denied" error on git bash? 通过 Git bash 在 Windows 上移动包含运行脚本的文件夹会引发“权限被拒绝” - Moving folder including the running script via Git bash on Windows raises “permission denied” Windows(使用 git bash)上的 Gcloud 命令正在记录错误:WindowsApps/python3:权限被拒绝 - Gcloud commands on Windows (using git bash) are logging ERROR: WindowsApps/python3: permission denied 在bash命令中使用括号git mv - Using parentheses in bash commands, git mv 当我使用git add'sampleFile.txt'时,Git给我“权限被拒绝” - Git gives me 'Permission Denied' when I use git add 'sampleFile.txt' 在Git Bash中使用'mkdir'命令时,如何取消'Permission denied'的限制? - How do I remove the restriction of 'Permission denied', when using the 'mkdir' command in Git Bash? 尝试在git bash上执行C代码时获得权限被拒绝错误 - Getting permission Denied Error when trying to execute my c code on git bash GIT权限被拒绝(公钥) - GIT permission denied (public key)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM