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
Next Level Git
Search
Daiki Hirakata
December 11, 2017
Technology
0
600
Next Level Git
社内向けのGit勉強会で使ったスライドです。
Daiki Hirakata
December 11, 2017
Tweet
Share
More Decks by Daiki Hirakata
See All by Daiki Hirakata
Firestoreコスト圧縮の旅
bigplants
0
28
Rails on Docker
bigplants
2
520
Road to k8s
bigplants
0
240
AWSを使っているならOpsWorksでDevOpsしよう!
bigplants
1
1.6k
Other Decks in Technology
See All in Technology
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
9
120k
visionOSでの空間表現実装とImmersive Video表示について / ai-immersive-visionos
cyberagentdevelopers
PRO
1
100
ガバメントクラウド単独利用方式におけるIaC活用
techniczna
3
260
Amazon_CloudWatch_ログ異常検出_導入ガイド
tsujiba
4
1.4k
クライアントサイドでよく使われる Debounce処理 をサーバサイドで3回実装した話
yoshiori
1
140
新R25、乃木坂46 Mobileなどのファンビジネスを支えるマルチテナンシーなプラットフォームの全体像 / cam-multi-cloud
cyberagentdevelopers
PRO
1
130
よくわからんサービスについての問い合わせが来たときの強い味方 Amazon Q について
kazzpapa3
0
210
2024-10-30-reInventStandby_StudyGroup_Intro
shinichirokawano
1
590
アジャイルと契約 エッセンシャル版 / Agile Contracts Essential Edition
fkino
0
110
LLMアプリをRagasで評価して、Langfuseで可視化しよう!
minorun365
PRO
3
300
AWS CDKでデータリストアの運用、どのように設計する?~Aurora・EFSの実践事例を紹介~/aws-cdk-data-restore-aurora-efs
mhrtech
4
610
Java x Spring Boot Warm up
kazu_kichi_67
2
480
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Code Reviewing Like a Champion
maltzj
519
39k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
167
49k
Building Your Own Lightsaber
phodgson
102
6k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
Happy Clients
brianwarren
97
6.7k
The Language of Interfaces
destraynor
154
24k
A designer walks into a library…
pauljervisheath
202
24k
How STYLIGHT went responsive
nonsquared
95
5.2k
Transcript
NEXT LEVEL GIT @bigplants
Who am I ? • Daiki Hirakata • Software Engineer
• Primary interests: DevOps, Docker, Kubernetes, Microservice Architecture, GCP @bigplants
Agenda • Introduction • Briefly explanation of Git • Psychological
barriers to using Git • Understanding “git flow” • What should we write commit log? • What should we do in this kind of situation? • OSS contribution is very easy!
Introduction
The gist • GitΛΤϯδχΞͷڞ௨ݴޠͱͯ͢͠ΜͳΓѻ ͑ΔΑ͏ʹ͢ΔࣄͰࣾશମͷίϥϘϨʔγϣ ϯͷଅਐͱੜ࢈ੑͷ্ΛਤΓ͍ͨɻ
Why do I say Git Git Git? • GitVCSͷσϑΝΫτ͔ͩΒɻ •
GitΤϯδχΞಉ࢜ͷίϛϡχέʔγϣϯͦͷͷ ɻ • άϩʔόϧਓࡐʹͳΔͨΊʹӳޠΛͤΔΑ͏ʹͳΔͷͱಉ͡Α͏ʹɺ ΤϯδχΞͳΒGit͘Β͍͢ΜͳΓѻ͑ΔΑ͏ʹͳ͓͖͍ͬͯͨɻ • ࠓϓϩμΫτͷߋ৽αΠΫϧͷதͰͳͯ͘ͳΒͳ͍ଘࡏɻ • GitHubͰࣾެ։͢Δ͜ͱʹΑͬͯɺΑΓΦʔϓϯʹͳΓιʔεͷԣల ։͕ग़དྷΔɺͭ·ΓձࣾશମͷφϨοδ͕ੵ͞ΕΔɻͦͯ͠ίϥϘ Ϩʔγϣϯ͕ՄೳʹͳΔɻ
Communication is very important! • ͲΜͳʹ༏ΕͨΤϯδχΞͰίϛϡχέʔγϣϯ͕͏·͘औΕͳ͍ͱ ೦ͳ͜ͱʹͳΔ߹͕͋Δɻ • େମͷϓϩδΣΫτ͕ෳਓͰ։ൃ͍ͯ͠ΔɻੈͷதʹࢄΒͬͯΔ༏ ΕͨϥΠϒϥϦͨͬͨҰਓͰ։ൃͰ͖ͳ͍ɻͦ͜ʹ։ൃऀͷ͍
͕٧·͓ͬͯΓɺ૬खͷྀɺؾΓ͕͋ͬͯॳΊཱͯ͢Δɻ • ίʔυΛಡΈ͘͢͢ΔɺࠩΛΘ͔Γ͘͢͢ΔࣄɺଞͷΤϯδχ ΞͱؔΘΔ্Ͱͱͯॏཁʹͳͬͯ͘Δɻ • ͯ͢ͷ׆ಈίϛϡχέʔγϣϯΛҙࣝͨ݁͠ՌͰ͋Δ͖ɻ • ͦͷίϛϡχέʔγϣϯखஈʹGit͏͚ͬͯͭɻ
ͪΐͬͱGitͷ͓͞Β͍Λ͠Α͏ʂ
Briefly explanation of Git
Source: https://qiita.com/yunico-jp/items/ 87bdd13971e82833f6bb
ϒϥϯνʹ͍ͭͯ • ϒϥϯνɺҎԼͷࡾछྨ • ϩʔΧϧϒϥϯν • ϦϞʔτϒϥϯν • ϦϞʔτϒϥϯν
ϩʔΧϧϒϥϯν • ϩʔΧϧϒϥϯνϩʔΧϧڥͰ࣮ࡍʹίϛο τ͕Մೳͳϒϥϯν
ϦϞʔτϒϥϯν • ϦϞʔτϒϥϯναʔό্ʹଘࡏ͢Δϒϥϯν • ྫ͑GitHub্ͷϦϙδτϦʹଘࡏ͢Δϒϥϯ ν • git pushͰߋ৽͞ΕΔ •
ීஈɺࢀর͢Δࣄ΄΅ͳ͍
ϦϞʔτϒϥϯν • ϦϞʔτϒϥϯνɺϩʔΧϧʹ࣋ͭϦ Ϟʔτϒϥϯνͷίϐʔɻ
git pullͷͳ͠ • git pullΛ͢Δͱɺ 1. ϦϞʔτϒϥϯνΛμϯϩʔυ͠ɺϦϞʔτϒϥϯνΛߋ৽ 2. ϦϞʔτϒϥϯνΛϩʔΧϧϒϥϯνʹϚʔδ
ͱ͍͏ྲྀΕʹͳΔɻ • git pull෦తʹɺ git fetch git merge origin <current_branch> Λ͍ͬͯΔɻ
git fetchͷͳ͠ • git fetchશϦϞʔτϒϥϯνͷ࠷৽ΛϦϞʔ τϒϥϯνʹίϐʔ͢Δɻ
ͦΖͦΖਏ͘ͳ͖ͬͯͨͷͰ ਤͰઆ໌͠·͢
αʔό (JU)VC ϩʔΧϧ ϦϞʔτϒϥϯν NBTUFS EFWFMPQ ϦϞʔτϒϥϯν ϩʔΧϧϒϥϯν PSJHJONBTUFS PSJHJOEFWFMPQ
NBTUFS )&"% EFWFMPQ ݱࡏͷঢ়ଶ
αʔό (JU)VC ϩʔΧϧ ϦϞʔτϒϥϯν NBTUFS EFWFMPQ ϦϞʔτϒϥϯν PSJHJONBTUFS PSJHJOEFWFMPQ git
fetch ϩʔΧϧϒϥϯν NBTUFS )&"% EFWFMPQ
αʔό (JU)VC ϩʔΧϧ ϦϞʔτϒϥϯν NBTUFS EFWFMPQ ϦϞʔτϒϥϯν ϩʔΧϧϒϥϯν PSJHJONBTUFS PSJHJOEFWFMPQ
NBTUFS )&"% git merge EFWFMPQ
GitͬͯΔͱͨ·ʹෆ҆ʹͳ Δ͕࣌͋Δɻɻ
Psychological barriers to using Git
͍ͭมߋͨ͠ͷ͔Θ͔Βͳ͍ϑΝΠϧ͕͍ͭ ࠩͰ͕͋ͬͯ͘Δ • όʔδϣϯཧରΛ໌֬ʹ͠Α͏ɻ • ༨ܭͳϑΝΠϧ.gitignoreͰແࢹ͠Α͏ɻ ͷͪ΄Ͳղઆ͠·͢ɻ
Push͢Δͱ͖͍ͭۓு͢Δɻଞͷਓʹ໎͔͚ ΔͷͰʁ • ͔ͯ͠͠masterϒϥϯν্Ͱpushͱ͔ͯ͠ ͳ͍ʁ ͨͬͨҰਓͷϓϩδΣΫτͳΒͳ͍͚Ͳɺͦ͏ ͡Όͳ͍߹Ί·͠ΐ͏ɻ • ඞͣࣗ༻ͷϒϥϯνΛ࡞ͯ͠࡞ۀ͠·͠ΐ͏ɻ ͜ΕͰ͍͘Βpushౖͯ͠໐ΒΕΔࣄ͋Γ·ͤ
Μɻ
τϥϒϧΛආ͚Δҝʹ࠷ݶͬ ͓͖ͯ͘ઃఆ • ݱࡏͷઃఆΛ֬ೝ git config --global --list
τϥϒϧΛආ͚Δҝʹ࠷ݶͬ ͓͖ͯ͘ઃఆ • Ϣʔβ໊ɺϝʔϧΞυϨεͷઃఆ git config --global user.name "John Doe"
git config --global user.email
[email protected]
τϥϒϧΛආ͚Δҝʹ࠷ݶͬ ͓͖ͯ͘ઃఆ • push͢Δࡍʹৗʹݱࡏͷϒϥϯνʹ͘Α͏ ʹ͢Δ git config --global push.default current
τϥϒϧΛආ͚Δҝʹ࠷ݶͬ ͓͖ͯ͘ઃఆ • վߦίʔυCRLFͷѻ͍ʹ͍ͭͯɻνΣοΫΞτ࣌Կม ͤͣίϛοτ࣌CRLF -> LF ʹม͢Δɻ git
config --global core.autocrlf input ※ core.autocrlf ϓϩδΣΫτʹΑΓ·͢ɻCRLFΛڐ༰͠ͳ͚ Ε͍͚ͳ͍γνϡΤʔγϣϯͷ߹ɺfalseΛࢦఆ͢Δɻ CRLFͷҙࣄ߲ɺҎԼͷهࣄ͕ࢀߟʹͳΓ·͢ɻ https://qiita.com/uggds/items/00a1974ec4f115616580
Կ͔͋ͬͨΒඞͣ֬ೝ • ݱࡏͷεςʔλε֬ೝ git status • ϩάΛ֬ೝ git log •
ϒϥϯνΛ֬ೝ git branch -a • ࠩΛ֬ೝ git diff <commit>
git statusใͷࢁ
Β͔ͨ࣌͠ʹͲ͏͢Ε͍͍͔Θ͔Β ͳ͘ͳΔɻͳΔ͘ͳ͔ͬͨࣄʹ͍ͨ͠ɻ • ޙ΄ͲɺτϥϒϧγϡʔςΟϯάͷσϞͰղ આ͠·͢ɻ
ͳΜͱͳ͘ෆ҆ͳ͘ͳ͚ͬͨ Ͳɺϒϥϯνͱ͔Ͳ͏ͬͯ ͬͨΒ͍͍͔Θ͔Βͳ͍ɻ
Understanding “git flow”
What is git-flow A successful Git branching model Source: http://nvie.com/
posts/a-successful-git- branching-model/
Why should we concern “git flow”? • ϓϩδΣΫτʹෳ։ൃऀɺෳͷׂͷਓ ͕͍Δͱ͖ʹঢ়ଶΛѲ͘͢͢͠ΔͨΊ •
ຊ൪ڥɺεςʔδڥͷࠩΛೝࣝ͢Δͨ Ί • ༷ʑͳঢ়گʹରԠͰ͖ΔΑ͏ʹ͢ΔͨΊ
How to?
develop branch • developϒϥϯνৗʹଘࡏ ͢Δɻ • GitHubͰϒϥϯνΛอޢͰ͖ ·͢ɻ • developϒϥϯνͲΜͲΜ
ਐΜͰ͍͘ɻ • ఆظతʹdevelopϒϥϯνͷ ߋ৽featureϒϥϯνʹऔΓ ࠐΉɻ
։ൃͷྲྀΕ 1. ௨ৗͷػೳՃɺόάमਖ਼develop͔Βfeatureϒϥ ϯνΛ࡞ɻ 2. featureϒϥϯνdevelopʹϚʔδͨ͠Βআ͢Δɻ 3. ࣍ͷνέοτͷ࡞ۀͷҝʹ·ͨdevelop͔Βϒϥϯν ࡞ɻ 4.
͜ͷ܁Γฦ͠ɻ
release branch • releaseϒϥϯνϦϦʔε४උʹ͏ɻ • ϦϦʔε४උʹೖͬͨΒreleaseϒϥϯν Λ࡞͢Δɻ • εςʔδϯάڥʹσϓϩΠɻ •
ϦϦʔεͷҝͷόάϑΟοΫεͳͲ releaseϒϥϯν͔ΒϒϥϯνΛ࡞ͯ͠ Ϛʔδ͢Δɻ • releaseϒϥϯνͰमਖ਼ͨ͠ͷ developϒϥϯνʹϚʔδ͢Δɻ • developϒϥϯνৗʹ࠷৽ʹͳΔΑ͏ ʹ͢Δɻ
master branch • masterϒϥϯνݴ͏·Ͱ ͳ͘Ӭଓϒϥϯνɻ • ຊ൪ڥ͕ಉظ͍ͯ͠Δɻ • releaseϒϥϯν͔Βmasterϒ ϥϯνʹϚʔδͯ͠ຊ൪ڥ
ʹσϓϩΠɻ • masterϒϥϯνʹϚʔδͨ͠ Β৽͍͠όʔδϣϯΛtagͱ͠ ͯ༩͢Δɻ
hotfix branch • hotfixϒϥϯνຊ൪ ڥͰͷۓٸͷόάϑΟο Ϋε༻ɻ • masterϒϥϯν͔Βϒϥ ϯνΛΔɻ •
masterϒϥϯνʹϚʔδ ͨ͠Βdevelopϒϥϯν ʹϚʔδ͢Δɻ
None
ͨͩɺඞͣ͜͠ͷ௨Γʹͳ Βͳͯ͘Α͍
࣮ࡍʹ͜Μͳӡ༻ΞϦ • releaseϒϥϯνΛӬଓԽͯ͠ εςʔδϯάڥͱಉظͤͯ͞ ͓͘ɻ • masterϒϥϯνʹϚʔδͨ͠ ΒɺmasterϒϥϯνΛdevelop ϒϥϯνʹϚʔδ͢Δɻ •
ཧ༝ɺreleaseϒϥϯνͷࠩ ΛmasterϒϥϯνʹϚʔδ ͢Δ·Ͱͷ࣌ؒ͘ͳ͍ͨΊɻ
tagͷͳ͠ • ίϛοτΛࢀর͘͢͢͠Δҝʹ໊લΛ͚ͭ Δ • ϦϦʔεόʔδϣϯ͕͔Γ͘͢ͳΔ
tagΛ͚ͭΔͱ͜Μͳ͍͍ࣄ͕ • ϦϦʔεόʔδϣϯΛҙࣝ͢ΔࣄʹΑΓίϛϡχέʔ γϣϯ͕ͱΓ͘͢ͳΔ ྫɿv2.1Ͱ͜ͷػೳͷڍಈͲ͏ͳ͍͔ͬͯͨʁ • λάʹνΣοΫΞτ͢Δࣄ͕Ͱ͖ΔͷͰ͙ʹա ڈͷϦϦʔε࣌ͷঢ়ଶͳͲΛ֬ೝ͢Δ͜ͱ͕Ͱ͖Δ git checkout
<tag_name>
tagͰΑ͘͏ίϚϯυ • λάͷҰཡදࣔ git tag --list • λάͷՃ git tag
-a <tag_name> -m <message> • λάͷৄࡉදࣔ git show <tag_name> • λάͷpush git push origin <tag_name>
όʔδϣϯ൪߸ͷ͚ํͷྫ • ϝδϟʔόʔδϣϯ ݟͨૢ࡞ੑ͕େ͖͘มΘΔมߋ • ϚΠφʔόʔδϣϯ όάϑΟοΫεվળͳͲͷมߋ • v2.5 ͜ͷ߹ɺ”2”͕ϝδϟʔόʔδϣϯɺ”5"͕ϚΠφʔ
όʔδϣϯ
ଞʹͲΜͳϑϩʔ͕͋Δͷʁ
GitHub flow • ӬଓϒϥϯνmasterϒϥϯνͷΈɻ • ֤ࣗɺmasterϒϥϯν͔ΒϒϥϯνΛͬ ͯmasterϒϥϯνʹϚʔδ͓ͯ͠ΘΓɻ • masterϒϥϯνৗʹσϓϩΠՄೳͳঢ়ଶ Ͱͳ͚Ε͍͚ͳ͍ɻ
• Git flowΑΓγϯϓϧɻ • ͜Ε͕ՄೳͳϓϩδΣΫτɺϓϩμΫτ ͷߋ৽αΠΫϧ͕ߴͰͳ͚Ε͍͚ͳ͍ɻ
ͦʔ͍͑ίϛοτϩάͬͯ ΈΜͳͲʔͯ͠Δʁ
What should we write commit log?
ίϛοτϩάͱʁ • ίϛοτ࣌ʹ͢ϝοηʔδɻ • ϓϩμΫτͷྺ࢙ͦͷͷɻ • ϨϏϡʔ࣌ͷॏཁͳใɻ ※ ίʔυϨϏϡʔͷࠓճׂѪ͠·͢ɻ
ίϛοτϩάͰؾΛ͚Δ͜ͱ • ޙ͔Βݟฦͯ͠มߋͷҙਤ͕Θ͔ΔΑ͏ʹ͢ Δɻ • ෳͷ༰Λಉ͡ϩάʹ͞ͳ͍ɻ • ͢ͰʹΘ͔ͬͯΔใΛೖΕͳ͍ɻ • ίϛοτϩάʹؔ࿈Issue൪߸Λ༩ɻ
͜Μͳίϛοτϩά ΊΑ͏
Կͷҝͷ࡞ۀͳͷ͔Θ͔Βͳ͍ git log --oneline
ใʹຒΕ͍ͯΔ git log --oneline
༨ܭͳใؚ͕·Ε͍ͯΔ git log --stat
͡Ό͋ΠέͯΔίϛοτϩάͬ ͯͲΜͳͷʁ
ྑ͍ྫ git log --oneline
ίϛοτϩάͷTips
ίϛοτϩάʹؔ࿈Issue൪߸Λ ༩ • ৄࡉͳใͨͲΓண͖͘͢ͳΔ • Φεεϝઌ಄Ͱͳ͘ߦʹ͚ͭΔࣄ ཧ༝ɺ͙͢ʹத͕Θ͔Βͳ͍ใ͔ͩΒɻ
಄ࣙΛ͚ͭͯमਖ਼ͷλΠϓΛ ໌֬ʹ͢Δ • Fix: όάमਖ਼ • Add: ৽نͷ(ϑΝΠϧ)ػೳՃ • Modify:
όάͰͳ͍ػೳͷमਖ਼ • Clean: ϦϑΝΫλϦϯάʹΑΔཧ • Remove: আ
ߋʹֆจࣈͰָ͘͠Θ͔Γ͢ ͘ ࢀߟࢿྉɿGitͷίϛοτϝοηʔδΛֆจࣈ͔Β࢝ΊΔ https://qiita.com/pocotan001/items/775cc77087be5562cc56
࡞ۀதʹෳͷमਖ਼͕ೖΓͦ͏ ͳ࣌ʁ • ྫ͑ɺػೳվमͷ࡞ۀதʹɺطଘͷόάΛ ݟ͚ͭͯ͠·ͬͨ߹ • Ұͭͷίϛοτϩάʹෳͷमਖ਼͕Ͳ͏ͯ͠ ೖͬͯ͠·͏Μ͚ͩͲɻɻɻ • ͔ͱ్͍ͬͯதͰίϛοτͨ͘͠ͳ͍ɻ
git stashΛͬͯҰ࣌తʹୀආ • ͋ͱͰઆ໌͢Δ͔Βͪΐͬͱͬͯͯɻ
ίϛοτϩά͏Θ͔ͬͨɻ ͦΖͦΖΒ͔ͨ࣌͠ͷ͠ ͯ͘Εɻ
What should we do in this kind of situation?
͜Μͳ࣌Ͳ͏͢Δʁ • ؒҧͬͨͷͰίϛοτऔΓফ͍ͨ͠ɻ • PushऔΓফ͍ͨ͠ɻ • ϓϧϦΫͷϚʔδΛऔΓফ͍ͨ͠ɻ • औΓফͨ͠Ϛʔδ͔ΒՃͰ࡞ۀ͍ͨ͠ɻ •
࡞ۀதʹۓٸͷׂΓࠐΈ͕ೖΓɺҰ୴࡞ۀ༰Λίϛοτ͠ͳ͍Ͱୀආ͠ͱ͖ ͍ͨɻ • ҎલɺൿີͷΩʔΛpushͯ͠͠·ͬͨɻաڈͷྺ࢙͔ΒऔΓআ͖͍ͨɻ • ͱʹ͔͘ԿΒ͔ͷૢ࡞ΛऔΓফ͍ͨ͠ɻ(ϩʔΧϧͷΈ)
DEMO
ؒҧͬͨͷͰίϛοτऔΓফ͠ ͍ͨ • લͷ߹ मਖ਼ͯ͠ɺ git add . git commit
--amend
PushऔΓফ͍ͨ͠ (ࣗͷϒϥϯ νલఏ) • git reset HEAD^ • git push
-f ※ ڧ੍pushͷҝɺӬଓϒϥϯνͰͬͯμϝɻઈରʂ ͬͪΌͬͨ߹͔ʹϝϯόશһʹใࠂɻ ࡉ͔͍͠·ͤΜ͕ɺ߹ʹΑͬͯଞͷਓ͕git pullͨ࣌͠ʹΤ ϥʔ͕ग़ΔͷͰ͔ͳΓհͰ͢ɻ ˞ GitHubͰ͜ͷࣗମΛ͙ҝʹϒϥϯνΛอޢ͢Δࣄ͕Ͱ͖· ͢ɻ͜Ε͓ͬͯ͘͠ɻ
࡞ۀதʹۓٸͷׂΓࠐΈ͕ೖΓɺҰ୴࡞ۀ ༰Λίϛοτ͠ͳ͍Ͱୀආ͠ͱ͖͍ͨ • ࡞ۀΛୀආ͢Δ git stash • ్தͷ࡞ۀͷҰཡදࣔ git stash
list • ్தͷ࡞ۀΛ෮ݩ git stash pop <stash> ࢀߟࢿྉɿhttps://qiita.com/fukajun/items/ 41288806e4733cb9c342
ҎલʹൿີͷΩʔΛpushͯ͠͠ ·ͬͨɻաڈͷྺ࢙͔Βຣফ͍ͨ͠ • git filter-branch -f --index-filter 'git rm --
cached --ignore-unmatch FILENAME' -- prune-empty --tag-name-filter cat -- --all git push -f ࢀߟهࣄ: https://qiita.com/iorionda/items/ 88d6329af997b5c5e748
ػີใͷऔΓѻ͍ʹेʹ ؾΛ͚ͭ·͠ΐ͏ Source: http://bit.ly/2jQ4ZmJ
ύεϫʔυΩʔͷใͳͲ gitignore͢Δ • త • ػີੑͷߴ͍ใϦϙδτϦʹؚΊͯͳΒͳ͍ɻ • ͚ͲɺαʔϏεͷಈ࡞্ඞཁʹͳΔ͔ΒઃఆϑΝΠ ϧʹΩʔใΛॻ͍ͯຊ൪ڥʹஔ͍͓͖͍ͯͨɻ •
ϩʔΧϧڥͰσʔλϕʔεͷଓͷҝʹઃఆϑΝ ΠϧΛஔ͍͓͖͍ͯͨɻ
ύεϫʔυΩʔͷใͳͲ gitignore͢Δ • .gitignoreϑΝΠϧΛ࡞ • ແࢹ͢ΔϑΝΠϧσΟϨΫτϦͷύεΛهࡌ • ϑΝΠϧͷத .env .idea
ͳͲ • جຊతʹɺ༨ܭͳϑΝΠϧgitignoreͰແࢹ͢Δ͠ɻ ྫ͑ɺIDEͷઃఆϑΝΠϧͳͲɻ͠ΐͬͪΎ͏্͕͕ࠩͬͯ͘Δ͕ɺݸਓ༻ͷ ઃఆϑΝΠϧͳͲɻ
.gitignoreͷҙ • طʹόʔδϣϯཧରʹͳ͍ͬͯΔϑΝΠϧ Λ.gitignoreϑΝΠϧʹՃͯ͠ແࢹͯ͘͠Ε ͳ͍ɻ • ͦ͏͍͏࣌ɺϑΝΠϧΛআ͢Δ git rm <file_name>
git commit
ͱʹ͔͘ԿΒ͔ͷૢ࡞ΛऔΓফ ͍ͨ͠ɻ(ϩʔΧϧͷΈ) • ྫ͑ɺؒҧͬͯgit reset --hard HEAD^^ͱ͔ͬͯ͠·ͬͨɻͳ Ͳ • gitͷૢ࡞ཤྺΛදࣔ
git reflog • ରͷૢ࡞ͷޙͷঢ়ଶʹ͢ git reset --hard HEAD@{<number>} ※ ͪͳΈʹ͜ͷૢ࡞ࣗମΛऔΓফ͢ࣄͰ͖·͢ɻ ࢀߟࢿྉɿhttps://qiita.com/yaotti/items/e37c707938847aee671b
ϒϥϯνΛޡͬͯআͯ͠͠·ͬ ͨ • gitͷૢ࡞ཤྺΛදࣔ git reflog • ରͷૢ࡞ͷޙͷঢ়ଶʹ͢ git branch
<branch_name> HEAD@{<number>}
ϓϧϦΫͷϚʔδΛऔΓফͨ͠ ͍ • 1. Ϧόʔτ͢Δ • Ϧόʔτͱɺมߋͷଧͪফ͠ίϛοτͷࣄ
ϓϧϦΫͷϚʔδΛऔΓফͨ͠ ͍ • 2. ϚʔδͷऔΓফ͠ϓϧϦΫΛൃߦ
ϓϧϦΫͷϚʔδΛऔΓফͨ͠ ͍ • 3. औΓফ͠ϓϧϦΫΛϚʔδ
औΓফͨ͠Ϛʔδ͔ΒՃͰ࡞ ۀ͍ͨ͠ • ϦόʔτͷϦόʔτΛ͢Δ ʁʁʁͬͯͳͬͨʁ • ྲྀΕΛઆ໌͢Δͱɺ ࠩA (master) ↓
ࠩB (master) ↓ ࠩBͷଧফ͠(ࠩAͱ͕ࠩͳ͍ঢ়ଶ) (master) ↓ ࠩBͷଧফ͠ͷଧফ͠ (revert-revert-branch) ↓ Ճमਖ਼ (revert-revert-branch) ↓ վΊͯϚʔδ (master)
औΓফͨ͠Ϛʔδ͔ΒՃͰ࡞ ۀ͍ͨ͠ • 3. ͰϚʔδͨ͠औΓফ͠ϓϧϦΫΛ͞ΒʹϦ όʔτ
औΓফͨ͠Ϛʔδ͔ΒՃͰ࡞ ۀ͍ͨ͠ • Ϧόʔτͯ͠Ϧόʔτͨ͠ϒϥϯνͰՃ࡞ۀ • ৄͪ͘͜͠ΒͷهࣄΛ https://qiita.com/bigplants/items/3d1d3ada97d0c86d2548
Կ͔͋ͬͨ࣌ͷखҾ͖ • GitͰΒ͔ͨ࣌͠ʹ͑Δ19ݸͷԞٛ https://qiita.com/muran001/items/ dea2bbbaea1260098051 ࠷ॳ͔Β͜Εհͤʔʂͱ͍͏ποίϛNG Ͱɻ
ͱ৭ʑ͖͚ͯͨ͠ͲɺҰ൪ ͍͑ͨࣄ͕·ͩ͋Δ
OSS contribution is very easy!
OSSʹߩݙ͠Α͏
ͳͥίϯτϦϏϡʔτ͢Δͷ͔ʁ • ීஈ͔ΒOSSͷԸܙΛड͚ͯ·͢ΑͶʁ ͨ·ʹԸฦ͠͠·͠ΐ͏ɻ • ࣗͷ׆ಈΛࣾ֎ͰΞϐʔϧͰ͖Δɻ • ࣗݾͷͷͨΊɻ
ίϯτϦϏϡʔτܾͯ͠͠ ͍ͷͰͳ͍ • ੈքதͷΤϯδχΞ͕ʑϓϧϦΫΛૹΓ߹ͬ ͍ͯΔɻ ͨͱ͑ͦΕ͕ΫιϓϧϦΫͩͱͯ͠ɻࣗͰ ͤΔͷ͕͋ͬͨΒɺ·ͣڪΕͣʹૹͬͯ ΈΑ͏ɻ
ίϯτϦϏϡʔτͷۙͳྫ • Ұ൪ۙͳͷ֎෦ͷϥΠϒϥϦɻ • ීஈ͔ΒࢁͷϥΠϒϥϦΛऔΓࠐΜͰ։ൃ ͯ͠·͢ΑͶʁ • ͦ͜ʹόά͕͋ͬͨΒͲ͏͠·͔͢ʁ
ίϯτϦϏϡʔτ·ͰͷྲྀΕ 1. ར༻͍ͯ͠ΔϥΠϒϥϦʹόάΛൃݟɻ 2. GitHubͰରͷϥΠϒϥϦͷϦϙδτϦΛϑΥʔΫɻ 3. ϑΥʔΫͨ͠ϦϙδτϦʹύεΛΓସ͑Δ(package.json, composer.json, Gemfile) 4.
ϒϥϯνͬͯमਖ਼ɺpushɻ 5. ϓϧϦΫΛൃߦɻ˞֤ϦϙδτϦͷίϯτϦϏϡʔγϣϯΨΠυΛཁ֬ೝ 6. ϓϧϦΫ͕Ϛʔδ͞Εɺόʔδϣϯ͕ߋ৽͞ΕͨΒɺύοέʔδͷύεΛߋ৽ (package.json)ɻ 7. Ҏ্
ϑΥʔΫͷϕετϓϥΫςΟε Railsͷྫ 1. GitHub্ͰϑΥʔΫ rails/railsΛϑΥʔΫ͢Δͱɺ <your_account>/rails͕࡞͞ΕΔ 2. git clone
[email protected]
:<your_account>/rails.git
3. ຊՈͷߋ৽ΛͰ͖ΔΑ͏ʹ͢Δ git remote add upstream
[email protected]
:rails/rails.git 4. ϒϥϯνΛͬͯ࡞ۀ͠push͢Δ ˞ masterͰ࡞ۀ͢ΔࣄͰ͖·͕͢ɺຊՈͷߋ৽Λै͢ΔҝʹmasterϒϥϯνͰ࡞ۀ͠ͳ͍Α͏ʹ͠·͢ 5. ϓϧϦΫΤετΛൃߦ ϚʔδઌͷϒϥϯνϓϧϦΫͷ༰ʹ͍ͭͯɺ֤ϦϙδτϦͷίϯτϦϏϡʔγϣϯΨΠυΛཁ֬ೝ
ຊՈͷߋ৽ΛऔΓࠐΉ 1. masterʹνΣοΫΞτ git checkout master 2. ຊՈͷϦϞʔτϒϥϯνΛߋ৽ git fetch
upstream git merge upstream/master
͜͜Ͱoriginͷখ • Α͘ొ͢ΔoriginͬͯԿͳͷʁ ࣮ϦϙδτϦURLͷͨͩͷΤΠϦΞε • git config --list --local ͯ͠ΈΔ
[email protected]
:<your_accout>/ rails.git • git pull origin masterͷΘΓʹɺ git pull
[email protected]
:<your_accout>/rails.git master Ͱಉ݁͡ՌʹͳΔ
͜͜Ͱoriginͷখ • ͭ·Γɺ৭ΜͳϦϙδτϦͷURLΛՃ͢Δࣄ͕ Ͱ͖Δ ͨͱ͑heroku͕͍͍ྫɻ git remote add heroku https://git.heroku.com/
<app_name>.git git push heroku master
GitΛͬͯҰஔ͔ΕΔΤϯ δχΞʹ͠Α͏ʂ
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠