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
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.1k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
110
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
受け取る人から提供する人になるということ
little_rubyist
0
230
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
290
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.1k
as(型アサーション)を書く前にできること
marokanatani
10
2.6k
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
Outline View in SwiftUI
1024jp
1
330
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Speed Design
sergeychernyshev
24
610
Typedesign – Prime Four
hannesfritz
40
2.4k
Unsuck your backbone
ammeep
668
57k
Optimizing for Happiness
mojombo
376
70k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Faster Mobile Websites
deanohume
305
30k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
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