書く動機
Rails チュートリアルで学んだことを覚えるために書く。
変更が終わったトピックブランチの状態を見る git status
command
$ git status
On branch test
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: nokonoko.rb
no changes added to commit (use "git add" and/or "git commit -a")
コミット git commit -a -m "コメント"
-aフラグはすべてのファイルへの変更を一括でコミットすることが出来る。
command
$ git commit -a -m "nokogiri_sample revised"
[test 60734eb] nokogiri_sample revised
1 file changed, 2 insertions(+), 2 deletions(-)
マージ git merge <ブランチ名>
ブランチでのファイル変更が終わったので、マスターブランチに切り替えて、git merge <ブランチ名>
コマンドでマスターブランチに変更を反映する。
command
$ git checkout master
Switched to branch 'master'
$ git merge test
Updating 5a58185..5d8a1ce
Fast-forward
nokonoko.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
トピックブランチの削除 git branch -D <トピックブランチ名>
この時点でトピックブランチが残っています。
トピックブランチを削除せずにそのまま残しておくことはよくあるそうですが、作成したトピックブランチが不要になったりすることもあるので、書いておく。
例では、トピックブランチtest
を削除してみる。
command
$ git branch
* master
test
$ git branch -D test
Deleted branch test (was 5d8a1ce).
$ git branch
* master