問題一覧に戻る
中級ブランチ
問題24: git branch -d - マージ済みブランチの削除
git branch -dコマンドで、マージ済みのブランチを安全に削除する方法を学びます。不要になったブランチを整理することで、リポジトリを清潔に保てます。
# ブランチをセットアップ
echo "Main content" > main.txt
git add main.txt
git commit -m "Initial commit"
git switch -c feature-test
echo "Test feature" > test.txt
git add test.txt
git commit -m "Add test feature"
# 機能をマージ
git switch main
git merge feature-test
# ブランチを削除
git feature-test
# 削除を確認
git branch