2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git ブランチ操作

Posted at

ブランチ確認

# git branch
# git branch
	* master

ブランチ作成

# git branch [ブランチ名]
  1. ブランチ作成
  2. ブランチ確認
# git branch test
# git branch
	* master
	  test

ブランチ切替

# git checkout [ブランチ名]
  1. ブランチ確認
  2. ブランチ作成
  3. ブランチ切替
  4. ブランチ確認
# git branch
	* master
# git branch test
# git checkout test
	Switched to branch 'test'
# git branch
	  master
	* test

ブランチ削除

# git branch -d [ブランチ名]
  1. ブランチ確認
  2. ブランチ削除
  3. ブランチ確認
# git branch
	* master
	  test
# git branch -d test
	Deleted branch test (was 0b6162d).
# git branch
	* master

ブランチマージ

# git merge [マージ元]
  1. ブランチ確認
  2. テストブランチ上でファイル修正
  3. テストブランチ上でステージング
  4. テストブランチ上でコミット
  5. マスターブランチへ切替
  6. テストブランチをマスターブランチへマージ
  7. テストブランチ削除
# 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

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?