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
CSC509 Lecture 14
javiergs
PRO
0
130
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
260
Go の GC の不得意な部分を克服したい
taiyow
2
770
return文におけるstd::moveについて
onihusube
1
860
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
270
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
140
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
930
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
770
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
命名をリントする
chiroruxx
1
390
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Become a Pro
speakerdeck
PRO
26
5k
Being A Developer After 40
akosma
87
590k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Faster Mobile Websites
deanohume
305
30k
Git: the NoSQL Database
bkeepers
PRO
427
64k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
Embracing the Ebb and Flow
colly
84
4.5k
Building Your Own Lightsaber
phodgson
103
6.1k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
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