![](/img/trans.png)
[英]Clone GIT Repository Subfolder into existing Repo with identical folder structure
[英]Clone a subfolder from git repo without the repo structure
我想克隆這個項目https://github.com/veista/smartthings的子文件夾,即 smartthings/custom_components/smartthings 但是所有相關問題的答案都保留了回購結構:my-dir/smartthings/custom_components/smartthings 和我想要以下結果:my-dir/smartthings(子文件夾,而不是 repo 根目錄)
可能嗎?
你可以:
git filter-repo
命令(基於python,首先 安裝)那是:
cd local/cloned/repo
git filter-repo --path custom_components/smartthings/ --path-rename custom_components/smartthings/:/
git remote set-url origin https://github.com/<me>/<newRepo>
git push
如果您使用一些蘇打水連接或按字節付費或其他方式,您還可以使用過濾支持主要的 Git 托管服務支持和 Git 的核心命令,
git clone -n --filter=tree:0 https://github.com/veista/smartthings
cd smartthings
git read-tree -um @:custom_components/smartthings
並檢查另一個提交git reset --soft $thatcommit; git read-tree -um @:custom_components/smartthings
git reset --soft $thatcommit; git read-tree -um @:custom_components/smartthings
。 其他一切都可以以類似的方式解決。
這真的不是 Git 的運行方式。 在任何實際使用中,僅獲取該死的回購會更加有效。 這個 repo 你只想要一塊是 508KB,包括結帳; 這是一個 188KB 的下載。 檢查問題答案的頁面負載超過了您可以節省的所有數據流量的總和,更不用說在任務上花費的人力時間和精力了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.