我需要從 git 存盤庫下載單個檔案(腳本)。我遵循了這篇文章并設法下載了專案(存盤庫)的根檔案夾中的檔案。但不幸的是,我不知道如何檢出目錄內的檔案。
我的問題是如何在檢出(下載)單個檔案時指定目錄內檔案的路徑?(例如,下面示例中來自 folderA 的 fileA.txt)
存盤庫示例:
|-folderA
|-fileA.txt
|-fileB.txt
|-fileC.txt
|-fileD.txt
我在 PC 上運行的 Git 命令:
git clone --branch develop -n https://bitbucket.host/.../my_repository.git // clone repository with no files
cd my_repository // navigate to repository folder
git fetch
git checkout HEAD fileD.txt // successfully downloads fileD.txt file
git checkout HEAD fileC.txt // successfully downloads fileC.txt file
git checkout HEAD "folderA/fileA.txt" // error: pathspec 'folderA/fileA.txt' did not match any file(s) known to git
git checkout HEAD "/folderA/fileA.txt" // fatal: Invalid path '/folderA': No such file or directory
uj5u.com熱心網友回復:
試著這樣說:
git checkout HEAD -- folderA/fileA.txt
(關于雙破折號的含義,請參見 Stack Overflow 問題,例如Git checkout double dashes 的含義)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/332862.html
標籤:混帐
下一篇:從部分提交訊息中構建提交訊息
