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
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
940
Macとオーディオ再生 2024/11/02
yusukeito
0
370
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
300
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
flutterkaigi_2024.pdf
kyoheig3
0
140
Quine, Polyglot, 良いコード
qnighy
4
650
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
110
Amazon Qを使ってIaCを触ろう!
maruto
0
410
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
210
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
役立つログに取り組もう
irof
28
9.6k
Featured
See All Featured
Done Done
chrislema
181
16k
Why Our Code Smells
bkeepers
PRO
334
57k
The Language of Interfaces
destraynor
154
24k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
Adopting Sorbet at Scale
ufuk
73
9.1k
How STYLIGHT went responsive
nonsquared
95
5.2k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
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