簡體   English   中英

使用 Flutter/Dart 克隆一個 Git 倉庫

[英]Clone a Git repo using Flutter/Dart

我想在 flutter/dart 中執行Process.start('cmd', ['/c', 'git', 'clone', repoLink, selectedDirectory]) 我的目標目錄不為空,因為當我執行正常的 git 克隆時,它會創建一個新文件夾,其中包含 repo 的名稱和其中的克隆。 但是當我將目標文件夾傳遞給git clone命令時,它會引發錯誤:

fatal: destination path 'd:\w' already exists and is not an empty directory.

當我得到 repo 名稱並創建一個目錄並將其添加到 selectedDirectory 時,它會在其中創建另一個名稱完全相同的文件夾。例如: D:\w\repoName\repoName\[repo files]

那么,如何使用 flutter 中的 Process 正確克隆 git 存儲庫?

更多信息:

我的目標目錄是這樣的:

D:\w\
  project1\
  project2\
  ...

在正常的克隆情況下,您可以簡單地 cd 到目標目錄D:\w並執行git clone <repo link>而目標目錄不能為空。

但是當你想在我處於不同的路徑時克隆那個 repo 時,git 給出了致命錯誤:

// git clone <repo-link> <target_folder>
C:\> git clone https://github.com/uesr/repo.git d:\w
fatal: destination path 'd:\w' already exists and is not an empty directory.

我試圖獲取回購名稱並創建一個目錄並將其添加到 selectedDirectory,但這樣做,git 克隆將創建另一個具有回購名稱的文件夾。 我想克隆到d:/w/repoName/[repo files]

我想使用 Process 來執行此操作,並使用機器上安裝的實際 git 軟件。

我可以使用這個過程來做到這一點:

Process.start('cmd', ['/c', 'cd', selectedDirectory, '&', 'git', 'clone', repoLink])

我無法添加多行來依次執行,但您可以使用 & 對一行命令執行此操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM