ブランチ確認
# git branch
例
# git branch
* master
ブランチ作成
# git branch [ブランチ名]
- ブランチ作成
- ブランチ確認
例
# git branch test
# git branch
* master
test
ブランチ切替
# git checkout [ブランチ名]
- ブランチ確認
- ブランチ作成
- ブランチ切替
- ブランチ確認
例
# git branch
* master
# git branch test
# git checkout test
Switched to branch 'test'
# git branch
master
* test
ブランチ削除
# git branch -d [ブランチ名]
- ブランチ確認
- ブランチ削除
- ブランチ確認
例
# git branch
* master
test
# git branch -d test
Deleted branch test (was 0b6162d).
# git branch
* master
ブランチマージ
# git merge [マージ元]
- ブランチ確認
- テストブランチ上でファイル修正
- テストブランチ上でステージング
- テストブランチ上でコミット
- マスターブランチへ切替
- テストブランチをマスターブランチへマージ
- テストブランチ削除
例
# git branch
master
* test
# echo $(LANG=C;date) >> date.txt
# git add date.txt
# git commit -m 'message' date.txt
[test 5906b81] message
1 files changed, 1 insertions(+), 0 deletions(-)
# git checkout master
Switched to branch 'master'
# git merge test
Updating d1884a2..5906b81
Fast-forward
date.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
# git branch -d test
Deleted branch test (was 5906b81).
ブランチ間の差分確認
# git diff [差分元ブランチ] [差分先ブランチ] [ファイル名]
例
# git diff master test