LoginSignup
4
3

More than 5 years have passed since last update.

gitでリモートブランチをすべて取得するシェルスクリプト

Posted at

備忘録代わりに。

git clone XXXとしたあとでリモートブランチのすべてのブランチを取得するスクリプト。

#!/bin/bash
for remote_branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do
    remote_name="$(echo -n "$remote_branch" | cut -d/ -f2)"
    branch_name="$(echo -n "$remote_branch" | cut -d/ -f3)"
    git checkout -b $branch_name $remote_name/$branch_name
done
git checkout master
4
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3