Skip to content

Instantly share code, notes, and snippets.

@oh-sky
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oh-sky/9967395 to your computer and use it in GitHub Desktop.
Save oh-sky/9967395 to your computer and use it in GitHub Desktop.
git branch関連と、GitHub Flowについてのメモ

ブランチの整理をしましょう

$ git branch -a の出力が画面に収まりますか?

branchでの作業が終わり、masterに取り込まれたら、branchを削除しましょう

ローカルのブランチを削除する

$ git fetch origin
$ git branch -d branch-name

branch-nameがmasterに取り込まれていない場合、エラーになります。
(変更をmasterに取り込んでないけど削除したい場合は$ git branch -D branch-name)

リモート(GitHub)のブランチを削除する

$ git push origin :branch-name

もしくは、GitHubのWebUIの操作で削除する

自分以外によって削除されたリモートの参照

GitHub上からは消えてるけど、git branch -rすると表示されるものの削除

$ git remote prune —dry-run origin #省略可
$ git remote prune origin

git branchコマンドのよく使うオプション

git branch —list ローカルのブランチ一覧
git branch -r リモートの参照一覧
git branch -a 上記2つを合わせたもの
git branch —merged masterに取り込み済みのブランチ一覧
git branch —no-merged masterに取り込まれていない変更が含まれるブランチ一覧

GitHub Flow を採用したい

https://gist.github.com/Gab-km/3705015
http://www.atmarkit.co.jp/ait/articles/1401/21/news042.html

メリット

  • 作業内容の確認、質問
  • 自分の関わりの薄いタスクの内容把握
  • 変更点の視認(余計な変更をしていないか、デバッグ用のコードが残っていないか)
  • etc

(近い)将来的には

  • masterへのpush禁止
  • 手元でmasterにmerge禁止
  • 自分のpull requestを自分でmergeするの禁止

とりあえずやってみよう

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment