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
Recoilを剥がしている話
kirik
5
6.8k
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
500
Zoneless Testing
rainerhahnekamp
0
120
暇に任せてProxmoxコンソール 作ってみました
karugamo
2
720
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
100
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
390
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
HTTP compression in PHP and Symfony apps
dunglas
2
1.7k
良いユニットテストを書こう
mototakatsu
8
2.6k
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
210
命名をリントする
chiroruxx
1
410
useSyncExternalStoreを使いまくる
ssssota
6
1.1k
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
427
64k
How STYLIGHT went responsive
nonsquared
95
5.2k
Automating Front-end Workflow
addyosmani
1366
200k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Designing for Performance
lara
604
68k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Facilitating Awesome Meetings
lara
50
6.1k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Documentation Writing (for coders)
carmenintech
66
4.5k
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