跳轉至

建立 2024-01-01 更新 2026-09-15

git clone

git clone 從遠端儲存庫複製完整專案到本機,包含歷史與分支。這是加入現有專案、或把 GitHub 上的作業拿到第二台電腦時的標準第一步。

基本用法

git clone <遠端儲存庫網址>

常用範例

從 GitHub 複製(資料夾名稱預設等於儲存庫名稱):

git clone https://github.com/user/repo.git

自訂本機資料夾名稱:

git clone https://github.com/user/repo.git my-project

已設定 SSH 時可用:

git clone git@github.com:user/repo.git

在 VS Code 則用命令選擇區的 Git: Clone,見 VS Code 與 Git。

影響的區域

一次準備好 remote(通常叫 origin)、local 與 workspace。之後用 git pull/git push 與遠端同步。

常見搭配

git remote -v    # 確認遠端網址
git pull         # 拿最新變更