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
29
Rails on Docker
bigplants
2
530
Road to k8s
bigplants
0
240
AWSを使っているならOpsWorksでDevOpsしよう!
bigplants
1
1.6k
Other Decks in Technology
See All in Technology
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
1
180
ドメイン名の終活について - JPAAWG 7th -
mikit
33
20k
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
120
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
3
200
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
ハイパーパラメータチューニングって何をしているの
toridori_dev
0
140
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
990
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
130
Terraform Stacks入門 #HashiTalks
msato
0
350
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
88
5.7k
Faster Mobile Websites
deanohume
305
30k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Typedesign – Prime Four
hannesfritz
40
2.4k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Building Applications with DynamoDB
mza
90
6.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Visualization
eitanlees
145
15k
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ΛͬͯҰஔ͔ΕΔΤϯ δχΞʹ͠Α͏ʂ
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠