--- title: 使用 Git Clone Remote Repository 的所有 Branch tags: Git --- # 使用 Git Clone Remote Repository 的所有 Branch ## 操作說明 `git clone`指令預設只會 clone master branch,如果想要 clone remote repository 的所有 branches,可以在進入本地 repository 資料夾後,執行以下命令: ```bash #!/bin/bash for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do git branch --track ${branch#remotes/origin/} $branch; done ``` 執行後可以使用 ```git branch``` 指令確認是否成功 --- ## 參考資料 [Git clone all remote branches locally.](https://coderwall.com/p/0ypmka/git-clone-all-remote-branches-locally)
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.