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 ライフを快適にする知られざるコマンドたち
Search
Tomoki Aonuma
August 27, 2013
Programming
48
10k
Git ライフを快適にする知られざるコマンドたち
Git 初心者〜中級者に向けて、目立たないけど便利なコマンドを紹介します。
Tomoki Aonuma
August 27, 2013
Tweet
Share
More Decks by Tomoki Aonuma
See All by Tomoki Aonuma
CDEvents+ReactiveCocoa でファイル監視
uasi
1
890
Other Decks in Programming
See All in Programming
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
470
リリース8年目のサービスの1800個のERBファイルをViewComponentに移行した方法とその結果
katty0324
5
3.5k
Synchronizationを支える技術
s_shimotori
1
150
外部システム連携先が10を超えるシステムでのアーキテクチャ設計・実装事例
kiwasaki
1
220
go.mod、DockerfileやCI設定に分散しがちなGoのバージョンをまとめて管理する / Go Connect #3
arthur1
10
2.3k
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
330
Amazon Neptuneで始めてみるグラフDB-OpenSearchによるグラフの全文検索-
satoshi256kbyte
4
310
CSC305 Lecture 13
javiergs
PRO
0
120
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
350
のびしろを広げる巻き込まれ力:偶然を活かすキャリアの作り方/oso2024
takahashiikki
1
400
Golang と Erlang
taiyow
8
1.9k
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
150
Featured
See All Featured
What's new in Ruby 2.0
geeforr
342
31k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
9
680
YesSQL, Process and Tooling at Scale
rocio
167
14k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
Facilitating Awesome Meetings
lara
49
6k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.8k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
Fireside Chat
paigeccino
32
3k
Into the Great Unknown - MozCon
thekraken
31
1.5k
The Language of Interfaces
destraynor
154
24k
4 Signs Your Business is Dying
shpigford
180
21k
Transcript
(JUϥΠϑΛ \ͪΐͬͱ ͬͱ ^ շదʹ͢Δ ΒΕ͟ΔίϚϯυͨͪ !VBTJ
VBTJ
w(JU)VCੜ wͣͬͱͬͯΔ wҰਓͰͬͯΔ
ͣͬͱҰਓͰͬͯΔ
$ git blame Document.h ca55733e (Tomoki Aonuma ... ad2d179e (Tomoki
Aonuma ... 95074544 (Tomoki Aonuma ... c7bc39f9 (Tomoki Aonuma ... 95074544 (Tomoki Aonuma ... ca55733e (Tomoki Aonuma ... ^02e6c80 (Tomoki Aonuma ... a3a5d708 (Tomoki Aonuma ... fc79def1 (Tomoki Aonuma ...
νʔϜͷ͜ͱ ͔Βͳ͍ʜ
ҰਓͰศརʹ ͏ํ๏ ڭ͑·͢
ΒΕ͟Δ ཱͪ ˑˑˑ ˒˒˒
git help
•ࠔͬͨΒHELP •Α͘͏ίϚϯυ΄ͲΑ͘มΘΔ •git help -a ←ίϚϯυҰཡ •git help -g ←ΨΠυҰཡ
git help <cmd>
wgit help config wgit help glossary w༻ޠू wgit help revisions
wHEAD^ͱ͔dev..masterͱ͔ git help <cmd>
ΒΕ͟Δ ཱͪ ˒ˑˑ ˒˒ˑ
git status -sb
git status -sb git status \ --short \ --branch
git status $ git status # On branch master #
Your branch is ahead of 'origin/mast # (use "git push" to publish your lo # # Untracked files: # (use "git add <file>..." to includ # # hoge nothing added to commit but untracked files present (use "git add" to track)
git status -sb $ git status -sb ## master...origin/master [ahead
1] ?? hoge
ΒΕ͟Δ ཱͪ ˒ˑˑ ˒˒ˑ
ls .git/hooks git help hooks
ls .git/hooks git help hooks •৭ʑͳλΠϛϯάͰΔϑοΫ •ίϛοτલޙ •Ϧϕʔεલ •νΣοΫΞτޙ…
ls .git/hooks git help hooks •Kobito ͷ։ൃͰ pre-commit ϑοΫͰ ιʔεϑΝΠϧ͕λʔήοτʹ
ؚ·Ε͍ͯΔ͔νΣοΫ •gem ‘xcodeproj’
ls .git/hooks git help hooks •Kobito ͷ։ൃͰ pre-commit ϑοΫͰ ιʔεϑΝΠϧ͕λʔήοτʹ
ؚ·Ε͍ͯΔ͔νΣοΫ •gem ‘xcodeproj’
ΒΕ͟Δ ཱͪ ˒˒ˑ ˒˒ˑ
git diff \ --patience
git diff --patience •ʢͪΐͬͱʣݡ͍ diff •͕ࠩಡΈ͘͢ͳΔʢ͔ʣ
ྫ void foo() { printf("foo\n"); } void foo() { printf("foo\n");
printf("foo\n"); } void bar() { printf("bar\n"); } ฤूޙ ฤूલ
git diff $ git diff a.c b.c ... @@ -1,4
+1,9 @@ void foo() { printf("foo\n"); + printf("foo\n"); + +} +void bar() { + printf("bar\n"); }
git diff --patience $ git diff --patience a.c b.c ...
@@ -1,4 +1,9 @@ void foo() { printf("foo\n"); + printf("foo\n"); } + +void bar() { + printf("bar\n"); +}
git diff --histogram •ʢ͏ͪΐͬͱʣݡ͍ diff •͕ࠩಡΈ͘͢ͳΔʢΑͶʁʣ
git config \ diff.algorithm •git config \ diff.algorithm \ (patience|histogram)
•;ͭ͏ͷ diff Λ͏ͱ͖ git diff \ --diff-algorithm=default
git config \ diff.algorithm •git log -U git format-patch
ʹӨڹ •࣮ͦΕΒͷίϚϯυʹ --patience ͳͲΛࢦఆͰ͖Δ
ΒΕ͟Δ ཱͪ ˒˒˒ ˒˒ˑ
git diff git apply outside worktree ( )
git diff •Git ϦϙδτϦͷ֎Ͱ͑Δ •;ͭ͏ͷ diff ΑΓศར •git diff --binary
•git diff --color •git diff --word-diff
git diff •Git ϦϙδτϦͷதͰ ҙͷ2ϑΝΠϧͷࠩΛऔΕΔ •git diff --no-index
git apply •Git ϦϙδτϦͷ֎Ͱ͑Δ •git diff ͷύονΛ ͯΔͱ͖ʹ •git diff
old new >patch git apply patch # old ͕ ফ͑Δʂ #(∵old+มߋ+վ໊==new)
ΒΕ͟Δ ཱͪ ˒˒˒ ˒ˑˑ
pushInsteadOf
pushInsteadOf ͳ͠ # HTTPS URL ͰΫϩʔϯ $ git clone https://github.com/foo/bar
# ... # ॻ͖ࠐΈݖݶΛΒͬͨʂ $ git push origin master Username for 'https://github.com': # ໘ʂ
pushInsteadOf $ cat ~/.gitconfig ... [url "
[email protected]
:"] " pushinsteadof =
"git://github.com/" " pushinsteadof = "https://github.com/"
pushInsteadOf ͋Γ # HTTPS URL ͰΫϩʔϯ $ git clone https://github.com/foo/bar
# ... # ॻ͖ࠐΈݖݶΛΒͬͨʂ $ git push origin master Total 0 (delta 0), reused 0 (delta 0) To
[email protected]
:foo/bar ...
ΒΕ͟Δ ཱͪ ˒˒˒ ˒˒ˑ
git new-workdir
•ϦϙδτϦͷ࡞ۀσΟϨΫτϦΛ ৽ͨʹ࡞Δ •git new-workdir \ <repository> \ <new_workdir_path> \ [<branch>]
git new-workdir
•contrib σΟϨΫτϦʹ͋Δ •/usr/local/share/git- core/contrib/workdir ͋ͨΓ git new-workdir
ΒΕ͟Δ ཱͪ ˒˒˒ ˒˒˒
git rebase -i \ --autosquash
--autosquash •ίϛοτϝοηʔδ͕ fixup! ͔ squash! Ͱ ࢝·ΔίϛοτΛࣗಈతʹ fixup/squash •fixup! ͷޙʹରͷίϛοτͷ
ϝοηʔδΛࢦఆʢจࣈͰOKʣ
--autosquash $ git log oneline a99e5d7 fixup! X d2cb153 fixup!
A c85fc65 Add Foo $ git rebase -i --autosquash c85fc65^ pick c85fc65 Add Foo fixup d2cb153 fixup! A pick a99e5d7 fixup! X
rebase.autosquash $ git config [--global] \ rebase.autosquash true ͍ͭͰ autosquash
None
Βͳ͍ίϚϯυ ͋Γ·͔ͨ͠ʁ
(JUʹ·ͩ·ͩ ίϚϯυΦϓγϣϯ͕ Ճ͞Ε͍ͯ·͢ ʢϦϦʔεϊʔτΛνΣοΫʂʣ
໘ന͍ίϚϯυΛ ݟ͚ͭͨΒ 2JJUBͰγΣΞʂ ʢએͰ͢ʣ
&OKPZ