git 重新再從github上pull 所有branch

要從 GitHub 重新拉取 所有分支,可以用以下步驟來完成:


🛠️ 操作流程

  1. 確認遠端名稱
    一般預設遠端是 origin,可以用:

    git remote -v
    

    來檢查。

  2. 抓取所有分支資訊

    git fetch --all
    

    這會更新本地的遠端分支資訊。

  3. 建立本地分支追蹤遠端分支
    如果要把所有遠端分支都拉到本地,可以用:

    
    for branch in $(git branch -r | grep -v '\->'); do
        git branch --track ${branch#origin/} $branch || true
    done
    
    • git branch -r 列出所有遠端分支

    • --track 建立本地分支並追蹤對應的遠端分支

    • || true 避免已存在的分支報錯

  4. 拉取所有分支內容

    git pull --all
    

    這會同步所有已追蹤的分支。


📌 簡化版指令

如果只是要更新所有分支(不一定要建立本地分支),只需要:

git fetch --all
git pull --all

⚠️ 注意事項

  • git pull --all 只會更新已經有追蹤的分支。
  • 如果你要「完整複製」所有分支,建議用 git clone --mirror,這會把所有 refs(包含分支、tag)都拉下來:
    git clone --mirror https://github.com/USERNAME/REPO.git
    

Also See

File14FileLast Modified
把目前repo 所有的branch都push 到github把目前repo 所有的branch都push 到github2:24 PM - January 12, 2026
把目前 branch 上的修改(尚未 commit 的檔案)直接帶到一個新的 branch把目前 branch 上的修改(尚未 commit 的檔案)直接帶到一個新的 branch2:24 PM - January 12, 2026
從 Windows 把 repo 搬到 WSL再一次性 push 所有 branch 到GitHub 這樣就能避開 aux 檔名問題從 Windows 把 repo 搬到 WSL再一次性 push 所有 branch 到GitHub 這樣就能避開 aux 檔名問題2:24 PM - January 12, 2026
git指定初始化的 branch 名稱git指定初始化的 branch 名稱2:24 PM - January 12, 2026
github上的repo clone下來check out 某一個dev branchgithub上的repo clone下來check out 某一個dev branch2:24 PM - January 12, 2026
github一台電腦同時使用兩個 GitHub 帳號github一台電腦同時使用兩個 GitHub 帳號2:24 PM - January 12, 2026
github actionsgithub actions2:24 PM - January 12, 2026
Git 裡查看 configurationGit 裡查看 configuration2:24 PM - January 12, 2026
git 恢復到最近一次 git pull狀態,取消本地修改git 恢復到最近一次 git pull狀態,取消本地修改2:24 PM - January 12, 2026
git 初始化與推送流程圖git 初始化與推送流程圖2:24 PM - January 12, 2026
git 中查看commit歷史資訊git 中查看commit歷史資訊2:24 PM - January 12, 2026
git 中修改檔名且保留原來commit紀錄git 中修改檔名且保留原來commit紀錄2:24 PM - January 12, 2026
git Remote 常見情境與操作git Remote 常見情境與操作2:24 PM - January 12, 2026
git GUI tool, SourceTreegit GUI tool, SourceTree2:24 PM - January 12, 2026