26
ソースコード管理システム よしおかひろたか mailto:[email protected] http://d.hatena.ne.jp/hyoshiok twitter @hyoshiok セキュリティ&プログラミングキャンプ 2011

VCS - Version Control System at Security and Programming camp 2011

  • View
    5.668

  • Download
    1

Embed Size (px)

DESCRIPTION

VCS - Version Control System at Security and Programming camp 2011 by Hiro Yoshioka

Citation preview

Page 1: VCS - Version Control System at Security and Programming camp 2011

ソースコード管理システム

よしおかひろたか

mailto:[email protected] http://d.hatena.ne.jp/hyoshiok twitter @hyoshiok セキュリティ&プログラミングキャンプ 2011

Page 2: VCS - Version Control System at Security and Programming camp 2011

目次

なぜソースコード管理システムが必要なのか

大規模分散開発

Gitの紹介

Page 3: VCS - Version Control System at Security and Programming camp 2011

バージョン管理システム

バージョン管理システムはなぜ必要なのか VCS (Version Control System), SCM (Source Code

Manager), RCS (Revision Control System)などとも呼ばれている。

変更を管理したい

複数の人と共同作業をしたい

Page 4: VCS - Version Control System at Security and Programming camp 2011

大規模分散開発

特徴 多くの人が開発に関与

それぞれ独立に開発をしていて他人の作業についてすべて知っているわけではない

開発場所も分散している

Page 5: VCS - Version Control System at Security and Programming camp 2011

ソフトウェア開発のワークフロー

ソフトウェアを変更するとき 機能追加、拡張、変更

バグフィックス

性能改善

リファクタリング(機能は変更しないけど、より保守しやすい実装へ変更するなど)

Page 6: VCS - Version Control System at Security and Programming camp 2011

ワークフロー

コミュニティーベースの開発の場合、様々な仕事がある。 テスト

バグ登録

バグのトリアージ(優先順度付け)

バグのアサイン

コードの修正

ドキュメント執筆。翻訳。

レビュー。

その他いろいろ

Page 7: VCS - Version Control System at Security and Programming camp 2011

ソフトウェア開発のワークフロー

ソースコードリポジトリから取り出す

変更する(コンパイルエラー、ビルドエラーを取り除く)

テストをする

期待どおりでない場合、(変更する、テストする)を繰り返す

ソースコードリポジトリへ戻す

コンフリクトがある場合、コンフリクトを解消するまで、上記を繰り返す

Page 8: VCS - Version Control System at Security and Programming camp 2011

リポジトリがなぜ必要なのか

リポジトリ:ソースコードの保管場所

複数の人が共通のコードで作業をしているから 共同作業のかなめ

Page 9: VCS - Version Control System at Security and Programming camp 2011

なぜバージョン管理が必要なのか

変更部分を知りたい なぜ、その変更をしたのか

どのように変更したのか

自分の変更を追加したときにプログラムが期待通りに動かなくなった原因を知りたい

誰が何をやっているか知りたい

プロジェクトの進捗を知りたい

いつからバグが入っているか知りたい

Page 10: VCS - Version Control System at Security and Programming camp 2011

バージョン管理システムの例

git subversion cvs sccs Rational Clearcase (商用製品 )

Microsoft Team Foundation Server (商用製品 )

Page 11: VCS - Version Control System at Security and Programming camp 2011

VCSへの Linuxでの要求事項*

分散開発を容易にする

何千人の開発者をも扱えること

高速で効率よく動作すること

完全性と信頼を維持すること

説明責任を強制すること

*実用 Git、 Jon Loeliger (著 ) 、吉藤 英明 (監訳 )、 ISBN: 978-4873114408

Page 12: VCS - Version Control System at Security and Programming camp 2011

VCSへの Linuxでの要求事項、2

不変性

アトミックなトランザクション

分散した開発に対応し後押しをすること

完全なリポジトリ

すっきりとした内部設計

自由という意味でのフリー

Page 13: VCS - Version Control System at Security and Programming camp 2011

Git

Linuxの創始者の Linus Torvaldsが必要性にかられて開発

分散型

特徴 高速

分散開発のサポート

ハッシュ (SHA1)による完全性の維持

Page 14: VCS - Version Control System at Security and Programming camp 2011

git の利用

help $ git help $ git help COMMAND $ git COMMAND --help

Page 15: VCS - Version Control System at Security and Programming camp 2011

ユーザ設定

コミッターと著者の設定 $ git config –globall user.name ”Your Name” $ git config –global user.email [email protected]

設定の確認 $ git config -l

Page 16: VCS - Version Control System at Security and Programming camp 2011

リポジトリの作成

既にあるリポジトリからのコピー $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git $ git clone https://github.com/ruby/ruby

新規に作成する $ git init

Page 17: VCS - Version Control System at Security and Programming camp 2011

変更

ファイルの追加、変更など $ git add ファイル

レポジトリへの反映 $ git commit

エディタが起動してコメント記入を求められる

$ git commit -m ”comments”

Page 18: VCS - Version Control System at Security and Programming camp 2011

差分

$ git diff

Page 19: VCS - Version Control System at Security and Programming camp 2011

履歴

$ git log $ git whatchanged

Page 20: VCS - Version Control System at Security and Programming camp 2011

レポジトリの更新

$ git pull レポジトリ名 外部のレポジトリとマージする

Page 21: VCS - Version Control System at Security and Programming camp 2011

二分探索

$ git bisect バグを発見したとき、どのバージョンからバグが混入したか調べる

$ git bisect start$ git bisect bad                 # Current version is bad$ git bisect good v2.6.13­rc2    # v2.6.13­rc2 was the last version                                 # tested that was good

Page 22: VCS - Version Control System at Security and Programming camp 2011

典型的なワークフロー

$ git clone レポジトリ 既存変更、テスト、デバッグなど

$ git add ファイル名 $ git commit $ git push レポジトリ

Page 23: VCS - Version Control System at Security and Programming camp 2011

付録:

githubについて コメントを英語で書くのがなぜ推奨されるのか

Page 24: VCS - Version Control System at Security and Programming camp 2011

github

https://github.com/ gitレポジトリのホスティングサービス

Ruby on Railsの開発などにも利用されている

無料でも使える

利用方法 アカウント作成

プロジェクト登録( git pushなどをして公開) what are you coding (日々の活動をコードで表現)

Page 25: VCS - Version Control System at Security and Programming camp 2011

コメントは英語で

インターネットは英語が公用語

英語で書く訓練になる

Page 26: VCS - Version Control System at Security and Programming camp 2011

参考書

入門 Git、濱野純、 ISBN:978-4798023809 実用 Git、 Jon Loeliger (著 ) 、吉藤 英明 (監訳 )、 ISBN: 978-4873114408