0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Git+Laravel】全リモートブランチを一括取得して最新化する手順

Last updated at Posted at 2025-11-05

はじめに

しばらく離脱していた案件に再度入ることとなりました。
リモートのブランチをすべて取得して、ローカルもデータベースも一気に最新にしたい
という場面で実行した手順をまとめた備忘録です。

手順

1,すべてのリモート情報を取得

リポジトリのディレクトリへ移動し、リモートの最新情報を取ってきます。

git fetch --all

2,リモートブランチを確認

現在リモートに存在するブランチ一覧を確認します。

git branch -r

3,リモートの全ブランチをローカルに展開

すべてのリモートブランチをローカルに作成します。
※既に存在しているブランチはスキップして続行します。

for branch in $(git branch -r | grep -v '\->'); do
  git branch --track "${branch#origin/}" "$branch" 2>/dev/null || true
done

4,各ブランチを最新状態に更新

for branch in $(git branch | sed 's/*//'); do
  git checkout $branch
  git pull
done

5,最新のコミット確認

それぞれのブランチの最新コミットを確認できます。

git log -1

6,migratとseedを実行

ブランチによってマイグレーションファイルやシーダーが増えていることがあるため、データベースも更新します。

./sail artisan migrate
./sail artisan db:seed

もしテーブル構成をリセットしたい場合:

./sail artisan migrate:fresh --seed

参考

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?