Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Gitの仕組みと用語 / GitHub Term
Search
kaityo256
PRO
October 01, 2021
Education
32k
54
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Gitの仕組みと用語 / GitHub Term
物理情報工学ソフトウェア開発演習
kaityo256
PRO
October 01, 2021
More Decks by kaityo256
See All by kaityo256
勾配ブースティングと決定木の話 / gradient boosting and decision trees
kaityo256
PRO
7
1.6k
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.8k
この講義について / 00-setup
kaityo256
PRO
2
440
GitHubによるWebアプリケーションのデプロイ / 07-github-deploy
kaityo256
PRO
2
360
演習:Gitの基本操作 / 04-git-basic
kaityo256
PRO
1
580
演習:Gitの応用操作 / 05-git-advanced
kaityo256
PRO
1
340
演習:GitHubの基本操作 / 06-github-basic
kaityo256
PRO
1
410
バージョン管理とは / 01-a-vcs
kaityo256
PRO
2
390
Gitの仕組みと用語 / 01-b-term
kaityo256
PRO
1
480
Other Decks in Education
See All in Education
コミュニティを通じた_キャリア設計のススメ_20260424.pdf
masakiokuda
0
360
Data Management and Analytics Specialisation
signer
PRO
0
1.9k
0526
cbtlibrary
0
200
0506
cbtlibrary
0
220
2026年度春学期 統計学 第6回 データの関係を知る(1)ー 相関関係 (2026. 5. 14)
akiraasano
PRO
0
170
LinkedIn
matleenalaakso
0
4.4k
We部コミュニティスライド2026-04-24
junhat6
0
190
Lectura 2 (PIT : Python Basico)
robintux
0
380
AI-Based Speaking Assessment of a Short-Term Study Abroad Program
uranoken
0
370
Info Session MSc Computer Science & MSc Applied Informatics
signer
PRO
0
300
Estimating Group × Time Interaction in Scale-Transformed CEFR-J Self-Assessment Scores: A Case in Study-Abroad Research
uranoken
0
140
生成AI時代のエンジニア育成について考えてみた
akasan
0
180
Featured
See All Featured
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
200
Joys of Absence: A Defence of Solitary Play
codingconduct
1
410
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
The agentic SEO stack - context over prompts
schlessera
0
840
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
650
The World Runs on Bad Software
bkeepers
PRO
72
12k
Documentation Writing (for coders)
carmenintech
77
5.4k
GraphQLとの向き合い方2022年版
quramy
50
15k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
590
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
GitHub's CSS Performance
jonrohan
1033
470k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
460
Transcript
1 39 Gitの仕組みと用語 慶應義塾大学理工学部物理情報工学科 渡辺 物理情報工学ソフトウェア開発演習
2 39 Gitは簡単ではない
3 39 git init git add git commit git status
git diff git log git clone git remote git fetch git switch git merge git rebase ローカルリポジトリの操作 ブランチの操作 状態や歴史の確認 リモートとのやりとり 「とりあえず」でも こんなにある
4 39 --abbrev-commit --abbrev[=<n>] --after=<date> --all --all-match --alternate-refs --ancestry-path --anchored=<text>
--author-date-order --author=<pattern> --basic-regexp --before=<date> --binary --bisect --boundary --branches[=<pattern>] --break-rewrites[=[<n>][/<m>]] --cc --check --cherry --cherry-mark --cherry-pick --children --color-moved-ws=<modes> --color-moved[=<mode>] --color-words[=<regex>] --color[=<when>] --combined-all-paths --committer=<pattern> --compact-summary --cumulative --date-order --date=<format> --decorate-refs- exclude=<pattern> --decorate-refs=<pattern> --decorate[=short|full|auto|no] --dense --dense --diff-merges=[options] --dirstat-by-file[=<param1,param2>…] --dirstat[=<param1,param2,…>] --do-walk --dst-prefix=<prefix> --encoding=<encoding> --exclude=<glob-pattern> --expand-tabs=<n> --ext-diff --extended-regexp --find-copies-harder --find-copies[=<n>] --find-object=<object-id> --find-renames[=<n>] --first-parent --fixed-strings --follow --format=<format> --full-diff --full-history --full-index --function-context --glob=<glob-pattern> --graph --grep-reflog=<pattern> --grep=<pattern> --histogram --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol --ignore-matching-lines=<regex> --ignore-missing --ignore-space-at-eol --ignore-space-change --ignore-submodules[=<when>] --indent-heuristic --inter-hunk-context=<lines> --invert-grep --irreversible-delete --ita-invisible-in-index --left-only --left-right --line-prefix=<prefix> --log-size --max-count=<number> --max-parents=<number> --merge --merges --min-parents=<number> --minimal --name-only --name-status --not --notes[=<ref>] --numstat --oneline --output-indicator-context=<char> --output-indicator-new=<char> --output-indicator-old=<char> --output=<file> --parents --patch --patch-with-raw --patch-with-stat --patience --perl-regexp --pickaxe-all --pickaxe-regex --pretty[=<format>] --raw --reflog --regexp-ignore-case --relative-date --relative[=<path>] --remotes[=<pattern>] --remove-empty --reverse --right-only --rotate-to=<file> --shortstat --show-linear-break[=<barrier>] --show-notes[=<ref>] --show-pulls --show-pulls --show-signature --simplify-by-decoration --simplify-merges --since=<date> --single-worktree --skip-to=<file> --skip=<number> --source --sparse --src-prefix=<prefix> --stat[=<width>[,<name-width>[,<count>]]] --stdin --submodule[=<format>] --summary --tags[=<pattern>] --text --textconv --topo-order --unified=<n> --until=<date> --walk-reflogs --word-diff-regex=<regex> --word-diff[=<mode>] --ws-error-highlight=<kind>
5 39 Gitは簡単ではない Gitにはコマンドが多い Gitはユニークな設計思想を持つ Gitは使い方の自由度が高い(人によって流儀が異なる) Gitに慣れていないとトラブルへの対処が難しい
6 39 Gitで使われる用語を一通り学ぶ 「コミット」や「ブランチ」など、バージョン管理 システムでは共通の単語が使われるが、ツールに よって意味や用法がかなり異なる 以下の説明はGitでの説明であることに注意
7 39 卒論プロジェクト grad fig ref doc 管理したいファイルやフォルダの集まりを「プロジェクト」と呼ぶ 以後、必要なファイルを全て含むトップレベルフォルダをプロジェクトと同一視する
8 39 リポジトリ ワーキングツリー .git Git管理下にあるプロジェクト Gitで管理されたプロジェクトには.gitというフォルダがある リポジトリ:履歴や状態を保存する場所 ワーキングツリー:作業中のファイルやフォルダ プロジェクト一つにリポジトリ一つ
9 39 .git .git 自分のPC サーバ ローカルリポジトリ リモートリポジトリ (ノンベアリポジトリ) (ベアリポジトリ)
10 39 ローカルリポジトリ (local repository) 手元のPCにあるリポジトリのこと ワーキングツリーを持つ リモートリポジトリ (remote repository)
リモート(ネットワークの向こう側)にある ワーキングツリーを持たない ベアリポジトリ (bare repository) ワーキングツリーを持たないリポジトリ 一般にリモートはベアリポジトリ
11 39 スナップショット(snapshot) ある時点でのプロジェクト全体の状態 Gitにある時点でのスナップショットを登録すること またはそのスナップショットそのもの コミット (commit)
12 39 Gitでは「歴史」を丸と線で表現する • 丸:ある時点の「状態」 • 線:二つの状態の関係(差分) 三日前 二日前 昨日
歴史 昨日から修正を加えたプロジェクト (スナップショット)
13 39 コミット:現在の状態を保存して「歴史」に加える 三日前 二日前 昨日 コミット 歴史 (スナップショット) 昨日から修正を加えたプロジェクト
(スナップショット)
14 39 三日前 二日前 昨日 歴史 今日 この玉それぞれを「コミット」と呼ぶ この玉を新たに作る作業を「コミットする」と呼ぶ commit
(名詞) : Gitの歴史のある「点」(スナップショット) commit (動詞): Gitの歴史に新たにスナップショットを付け加えること https://git-scm.com/docs/gitglossary A Git Glossary
15 39 歴史上の任意の地点に戻ることができる 今日の状態 二日前の状態 今日 昨日 二日前 三日前 今日
昨日 二日前 三日前 ワーキングツリー コミットはセーブファイルのようなもの
16 39 歴史上の任意の地点を比較できる 今日 昨日 二日前 三日前 デバッグに極めて有用
17 39 Gitには三種類の場所がある ワーキングツリー(workingtree) 現在修正中のプロジェクトファイルがある場所 インデックス (index) ステージングをする場所 コミットするスナップショットを用意する リポジトリ
(repository) 歴史(コミット)を保存する場所
18 39 本番環境に反映させる前に準備をする場所 ローカルPCで修正 ステージング環境 本番環境 ローカルPC ここで動作テスト 本番環境へ反映 ステージング環境
ステージング環境に修正を反映すること ステージング
19 39 ワーキングツリー インデックス リポジトリ file1 file2 まだGit管理下に 置かれていない Gitの初期化直後
20 39 ワーキングツリー インデックス リポジトリ file1 file2 ステージング file1 file2
ワーキングツリーの状態(スナップショット)をインデックスに登録
21 39 ワーキングツリー インデックス リポジトリ file1 file2 コミット file1 file2
インデックスにステージングされた状態をリポジトリに登録 file1 file2
22 39 Q: なぜインデックスがあるの? A: 複数の修正がある時、一部の修正 を選んでコミットを作るため
23 39 file1 file2 file1 file2 最後にコミットした状態からfile1とfile2を修正した ワーキングツリー インデックス リポジトリ
file1 file2
24 39 file1 file2 file1 file2 file1だけステージングする ワーキングツリー インデックス リポジトリ
file1 file2
25 39 file1 file2 file1 file2 コミットする ワーキングツリー インデックス リポジトリ
file1 file2
26 39 file1 file2 file1 file2 file2も同様にステージング、コミットする ワーキングツリー インデックス リポジトリ
file1 file2
27 39 file1 file2 file1 file2 file1 file2 こんな歴史ができあがった file1とfile2を追加
file1を修正 file2を修正 Gitでは積極的に歴史を作成、改変する
28 39 Gitでは歴史を積極的に改変する Gitでは歴史が分岐することがある Gitにおいて歴史操作の手段として使うのがブランチ
29 39 初期化直後 最初のコミット main main 次のコミット main さらに次のコミット main
ブランチ (branch) コミットにつくラベルのようなもの デフォルトでmainというブランチが用意される 自由に作ることができる コミットされると一緒に動く
30 39 main branch ブランチ作成直後 main branch HEAD ブランチの切り替え main
branch HEAD コミット HEAD カレントブランチ (current branch) 「今見ているブランチ」のこと HEADというラベルが指す コミットにより動くのはカレントブランチのみ
31 39 main branch branchを 見ている状態 HEAD main branch mainに
切り替える HEAD main branch コミットする HEAD ブランチを切り替えながらコミットをすると 一般に歴史が分岐する
32 39 main HEAD 通常の状態 main HEAD detached HEAD状態 HEADがブランチを経由して
コミットを指している HEADがブランチから外れ コミットを直接指している 通常、HEADはブランチを指しているが、HEADが直接 コミットを指す状態を頭が取れた(detached HEAD)状態 と呼ぶ
33 39 Gitでは、原則としてデフォルトブランチ(main)で作業しない 別のブランチで作業し、作業が一段落したらmainに取り込む この取り込む作業をマージと呼ぶ マージ(merge) あるブランチの修正を、別のブランチに取り込むこと
34 39 main branch mainの スナップショット branchの スナップショット main branch
ファイル追加 mainからbranchへ更新する ための「差分」 玉:スナップショット 線:スナップショット間の差分
35 39 main = + コミット (スナップショット) 修正(パッチ) branch ファイル追加
次のコミット (スナップショット) main branch スナップショット(玉)に、パッチ(線)を適用すると、次のスナップショット(玉)になる
36 39 main branch main branch 修正を取り込みたいブランチが、もう一方のブ ランチの直接の祖先である場合、ブランチを移 動するだけでマージが完了する これをFast-forwardマージ(早送りマージ)と呼ぶ
37 39 main branch main branch 歴史が分岐している場合、マージにより歴史が 合流する HEAD HEAD
新たに作られるコミットをマージコミット(merge commit)と呼ぶ
38 39 main branch main branch Fast Forwardマージできる場合でもマージコミットを作ることができる Fast forwardマージすると、マージ元がどこで分岐したかの情報が失われる
main branch main branch
39 39 コミット(名詞):スナップショット コミット(動詞):スナップショットの登録 インデックス:コミットの前に修正を登録する場所 ステージング:インデックスに修正を登録すること ブランチ:コミットについたラベル マージ:二つのブランチの修正を一つにまとめること Gitの歴史は「丸」と「線」で表現する 「丸」がスナップショット、「線」が差分を表す
今日ここだけは覚えて欲しい