New branch

----------------------------------------------
-- ユーザ
----------------------------------------------
# masterから新しいbranchを作成
$ git branch new-branch master

# 作業branchに移動
$ git checkout new-branch

# 作業
$ vim new-file.txt
$ vim add.txt

# 新規ファイルの追加
$ git add new-file.txt

# 既存ファイルの削除
$ git rm test.txt  
　　→　rm test.txt  ( または普通にrmでもOK　）

# 新規ファイルの作成（addはなし）
$ echo "new-file2.txt" > new-file2.txt


# 作業ヘッダを確認
$ git status
---------------------------------------------------
# On branch new-branch
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   new-file.txt
#       deleted:    test.txt
#
# 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:   add.txt
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       new-file2.txt
---------------------------------------------------

# 修正の取り消し
$ git checkout test.txt
$ git checkout add.txt

$ git status
---------------------------------------------------
# On branch new-branch
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   new-file.txt
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       new-file2.txt
---------------------------------------------------

# commit実行
$ git commit
[new-branch 246de1f] いろいろやりました
 2 files changed, 3 insertions(+), 0 deletions(-)
 create mode 100644 new-file.txt
 create mode 100644 new-file2.txt

# pull requestを投げる
$ git push origin new-branch
To git@github.com:amekure/test
 * [new branch]      new-branch -> new-branch


# 変更が加えられたファイルを自動検出してコミット
$ git commit -a
[new-branch 0a5d4cf] 追加コミットです
 2 files changed, 2 insertions(+), 5 deletions(-)
 delete mode 100644 test.txt

# pull requestを投げる
$ git push origin new-branch


# 画面にアクセス
https://github.com/amekure/test/compare/master...new-branch?expand=1

----------------------------------------------
-- 別のユーザ
----------------------------------------------
# フェッチ
$ git fetch
From github.com:amekure/test
   9263f7b..cd594da  master     -> origin/master
 * [new branch]      new-branch -> origin/new-branch

# フェッチするとheadにnew-branchができるけど、まだ自分のrepoにはない
$ git branch
* master

# origin/new-branchを自分のrepoにコピー
$ git checkout -b new-branch origin/new-branch
Branch new-branch set up to track remote branch new-branch from origin.
Switched to a new branch 'new-branch'

# できあがり
$ git branch
  master
* new-branch

# 差異を確認
$ git diff master new-branch

# 問題なければmergeしてbranchを削除
$ git checkout master
$ git merge master new-branch
$ git branch -d new-branch
Deleted branch new-branch (was cd594da).