我最初只是使用copy
,但我得到了這個輸出:
C:\repos\AutomatedBuildTesting (master -> origin)
(2020-09-18 8:49:01.12) λ copy ".hooks/*" ".git/hooks/*"
commit-msg
The system cannot find the file specified.
0 file(s) copied.
所以我嘗試了xcopy
一些事情,最終發現只有包含F
顯示完整文件名的標誌時它才會複製。誰能解釋一下嗎?
C:\repos\AutomatedBuildTesting (master -> origin)
(2020-09-18 8:48:32.95) λ xcopy ".hooks/*" ".git/hooks/*"
0 File(s) copied
C:\repos\AutomatedBuildTesting (master -> origin)
(2020-09-18 8:48:58.07) λ xcopy ".hooks/*" ".git/hooks/*" /F
Overwrite C:\repos\AutomatedBuildTesting\.git\hooks\commit-msg (Yes/No/All)? y
C:\repos\AutomatedBuildTesting\.hooks\commit-msg -> C:\repos\AutomatedBuildTesting\.git\hooks\commit-msg
1 File(s) copied
答案1
/
你用而不是寫出你的路徑\
。如果你將它們更改為\
它應該可以工作。我無法確切地告訴你為什麼它與 /f 一起工作而不是不與 /f 一起工作,但我從經驗中知道,將路徑寫為/
而不是\
對其進行不同的處理。
我假設包含參數時,cmd 能夠計算出該參數/
是路徑的一部分,而不是參數,因此可以正確處理命令。