SlideShare a Scribd company logo
1 of 22
Download to read offline
Git: Basic to Advanced
Yodalee <lc85301@gmail.com>
Before start
某:小弟我想知道merge, cherry什麼的, rebase還有reflog
某:可以的話 stash 順便
某:log --graph介紹一下
某:我只會commit嗚嗚
某:remote的概念可以介紹一下呀
某:我不會交女朋友呀(炸
(╯-_-)╯ ~╩╩ , man git-XXX (無誤)
Git: Basic
git init
git add
git commit
Extend Reading Material:
http://johnjohnlys.blogspot.tw/2012/08/git-part-1.html
Git Basic
Git: Reference
➔ git branch
➔ git tag
➔ HEAD, ORIG_HEAD, FETCH_HEAD
Notice:
1. Each reference points to a commit (Hash)
2. Low cost to move a reference (FF)
Git: Reference
Git: Remote
● Remote and Local
are independent.
● Use fetch/push to
get/set remote data.
Git rebase
Cut down a branch, connect to other
Steps:
1. Checkout the new-base
2. Re-apply commits
3. Stop if conflict
Git rebase -i
Interactive Rebase, you can:
● Change content(edit)
● Change message(reword)
● Change order
● Combine/Split commit(squash, reset)
● Run command(exec)
Extend Reading Material:
http://blog.yorkxin.org/posts/2011/07/29/git-rebase/
Git rebase
!rebase 有機會竄改歷史!
在已經merge 的branch 上rebase 會怎麼樣?
➔ = = 建議千萬別這樣做..上次有人這樣 結果把分枝弄得一團亂..
➔ 樓上..然後呢@@
➔ 就把分枝弄得一團亂 很不方便..
git stash
● Temporary store the changes you made.
● Useful with rebase
Basic usage: stash <push, pop, list>
Extend Reading Material:
http://yodalee.blogspot.tw/2013/12/git-stash.html
git format-patch, am
● git format-patch <Ref>
○ generate patches
● git am <path-to-patch>
○ Apply patches
git bisect
Find the commit that changes somthing, steps:
1. bisect start
2. Set “bisect bad”, “bisect good”
3. Keep testing; set bad or good
4. Find the commit
Extend Reading Material:
http://yodalee.blogspot.tw/2014/08/git-bisect.html
git cherry-pick
Pick out the change in some commit.
● -n, --no-commit: allow you edit, commit
manually
Not very useful, actually.
Git inside
ls * in .git:
● Object/: Data
● Refs/: Reference
● Logs/: Change to Reference
● other files
Extend Reading Material:
http://git-scm.com/docs/gitrepository-layout
Git reflog
● View the list of HEAD movement. record the
Hash and action
● Log when you move reference by
<commit, rebase, reset, checkout>
If you get the Hash, you can recover it.
Git fsck
● Fsck check repository integrity, find dangling
commits.
● Even reflog is deleted or not record, ex:
git branch -D some-branch
rm -Rf .git/logs/
Git gc
● Git do 'git gc --auto' automatically, it will
○ Pack the loose files (refs->packed-refs)
○ Delete the Non-reference files.
Git filter-branch
Filter out some commits, and do some change.
ex. git filter-branch --msg-filter “echo XD” branch
--Change all commit message into “XD”
ex. git filter-branch --index-filter “rm xxx” branch
--Delete file from git repository
Extend Reading Material:
http://yodalee.blogspot.tw/2014/06/git-gc.html
Git filter-branch
!filter-branch 就是要更動歷史!
在已經merge 的branch 上filter-branch會怎麼
樣?
➔ = = 建議千萬別這樣做..上次有人這樣 結果把分枝弄得一團亂..
➔ 樓上..然後呢@@
➔ 就把分枝弄得一團亂 很不方便..
Git useful tool
Linux: gitk, gitg
https://wiki.gnome.org/Apps/Gitg/
MacOS:
http://gitx.frim.nl/
Windows: X! I don’t know
The End
● Git is POWERFUL. With basic skills, it can
fulfill daily requirement.
● Hope everyone can become Git Master

More Related Content

What's hot

Git tutorial
Git tutorialGit tutorial
Git tutorialmobaires
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use ItDaniel Kummer
 
Version Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleVersion Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleGaurav Kumar Garg
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messesKatie Sylor-Miller
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsth507
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introductionrschwietzke
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial IJim Yeh
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeMd Swawibe Ul Alam
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 

What's hot (20)

Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git basics
Git basicsGit basics
Git basics
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Version Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleVersion Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an example
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git commands
Git commandsGit commands
Git commands
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commands
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
 
Git in 5 Minutes
Git in 5 MinutesGit in 5 Minutes
Git in 5 Minutes
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Git for the absolute beginners
Git for the absolute beginnersGit for the absolute beginners
Git for the absolute beginners
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 

Similar to Git: basic to advanced

Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 
Git tech talk
Git tech talkGit tech talk
Git tech talkrazasayed
 
Honestly Git Playground 20190221
Honestly Git Playground 20190221Honestly Git Playground 20190221
Honestly Git Playground 20190221Shinho Kang
 
Getting some Git
Getting some GitGetting some Git
Getting some GitBADR
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
Git cheat-sheets
Git cheat-sheetsGit cheat-sheets
Git cheat-sheetsozone777
 
Git slides
Git slidesGit slides
Git slidesNanyak S
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?9 series
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commandsZakaria Bouazza
 
Git Basics 1 Carenza
Git Basics 1 CarenzaGit Basics 1 Carenza
Git Basics 1 CarenzaPeter Carenza
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 

Similar to Git: basic to advanced (20)

Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
Git tech talk
Git tech talkGit tech talk
Git tech talk
 
Git basics 2
Git basics 2Git basics 2
Git basics 2
 
Git
GitGit
Git
 
Honestly Git Playground 20190221
Honestly Git Playground 20190221Honestly Git Playground 20190221
Honestly Git Playground 20190221
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Use Git like a pro - condensed
Use Git like a pro - condensedUse Git like a pro - condensed
Use Git like a pro - condensed
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Git cheat-sheets
Git cheat-sheetsGit cheat-sheets
Git cheat-sheets
 
Git slides
Git slidesGit slides
Git slides
 
Intro to Git
Intro to GitIntro to Git
Intro to Git
 
Git: Git'ing the Basic
Git: Git'ing the BasicGit: Git'ing the Basic
Git: Git'ing the Basic
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commands
 
Git Basics 1 Carenza
Git Basics 1 CarenzaGit Basics 1 Carenza
Git Basics 1 Carenza
 
Git of every day
Git of every dayGit of every day
Git of every day
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 

More from Yodalee

COSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdfCOSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdfYodalee
 
rrxv6 Build a Riscv xv6 Kernel in Rust.pdf
rrxv6 Build a Riscv xv6 Kernel in Rust.pdfrrxv6 Build a Riscv xv6 Kernel in Rust.pdf
rrxv6 Build a Riscv xv6 Kernel in Rust.pdfYodalee
 
Gameboy emulator in rust and web assembly
Gameboy emulator in rust and web assemblyGameboy emulator in rust and web assembly
Gameboy emulator in rust and web assemblyYodalee
 
Make A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst FrameworkMake A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst FrameworkYodalee
 
Build Yourself a Nixie Tube Clock
Build Yourself a Nixie Tube ClockBuild Yourself a Nixie Tube Clock
Build Yourself a Nixie Tube ClockYodalee
 
Use PEG to Write a Programming Language Parser
Use PEG to Write a Programming Language ParserUse PEG to Write a Programming Language Parser
Use PEG to Write a Programming Language ParserYodalee
 
Introduction to nand2 tetris
Introduction to nand2 tetrisIntroduction to nand2 tetris
Introduction to nand2 tetrisYodalee
 
Office word skills
Office word skillsOffice word skills
Office word skillsYodalee
 

More from Yodalee (8)

COSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdfCOSCUP2023 RSA256 Verilator.pdf
COSCUP2023 RSA256 Verilator.pdf
 
rrxv6 Build a Riscv xv6 Kernel in Rust.pdf
rrxv6 Build a Riscv xv6 Kernel in Rust.pdfrrxv6 Build a Riscv xv6 Kernel in Rust.pdf
rrxv6 Build a Riscv xv6 Kernel in Rust.pdf
 
Gameboy emulator in rust and web assembly
Gameboy emulator in rust and web assemblyGameboy emulator in rust and web assembly
Gameboy emulator in rust and web assembly
 
Make A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst FrameworkMake A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst Framework
 
Build Yourself a Nixie Tube Clock
Build Yourself a Nixie Tube ClockBuild Yourself a Nixie Tube Clock
Build Yourself a Nixie Tube Clock
 
Use PEG to Write a Programming Language Parser
Use PEG to Write a Programming Language ParserUse PEG to Write a Programming Language Parser
Use PEG to Write a Programming Language Parser
 
Introduction to nand2 tetris
Introduction to nand2 tetrisIntroduction to nand2 tetris
Introduction to nand2 tetris
 
Office word skills
Office word skillsOffice word skills
Office word skills
 

Recently uploaded

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 

Recently uploaded (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 

Git: basic to advanced

  • 1. Git: Basic to Advanced Yodalee <lc85301@gmail.com>
  • 2. Before start 某:小弟我想知道merge, cherry什麼的, rebase還有reflog 某:可以的話 stash 順便 某:log --graph介紹一下 某:我只會commit嗚嗚 某:remote的概念可以介紹一下呀 某:我不會交女朋友呀(炸 (╯-_-)╯ ~╩╩ , man git-XXX (無誤)
  • 3. Git: Basic git init git add git commit Extend Reading Material: http://johnjohnlys.blogspot.tw/2012/08/git-part-1.html
  • 5. Git: Reference ➔ git branch ➔ git tag ➔ HEAD, ORIG_HEAD, FETCH_HEAD Notice: 1. Each reference points to a commit (Hash) 2. Low cost to move a reference (FF)
  • 7. Git: Remote ● Remote and Local are independent. ● Use fetch/push to get/set remote data.
  • 8. Git rebase Cut down a branch, connect to other Steps: 1. Checkout the new-base 2. Re-apply commits 3. Stop if conflict
  • 9. Git rebase -i Interactive Rebase, you can: ● Change content(edit) ● Change message(reword) ● Change order ● Combine/Split commit(squash, reset) ● Run command(exec) Extend Reading Material: http://blog.yorkxin.org/posts/2011/07/29/git-rebase/
  • 10. Git rebase !rebase 有機會竄改歷史! 在已經merge 的branch 上rebase 會怎麼樣? ➔ = = 建議千萬別這樣做..上次有人這樣 結果把分枝弄得一團亂.. ➔ 樓上..然後呢@@ ➔ 就把分枝弄得一團亂 很不方便..
  • 11. git stash ● Temporary store the changes you made. ● Useful with rebase Basic usage: stash <push, pop, list> Extend Reading Material: http://yodalee.blogspot.tw/2013/12/git-stash.html
  • 12. git format-patch, am ● git format-patch <Ref> ○ generate patches ● git am <path-to-patch> ○ Apply patches
  • 13. git bisect Find the commit that changes somthing, steps: 1. bisect start 2. Set “bisect bad”, “bisect good” 3. Keep testing; set bad or good 4. Find the commit Extend Reading Material: http://yodalee.blogspot.tw/2014/08/git-bisect.html
  • 14. git cherry-pick Pick out the change in some commit. ● -n, --no-commit: allow you edit, commit manually Not very useful, actually.
  • 15. Git inside ls * in .git: ● Object/: Data ● Refs/: Reference ● Logs/: Change to Reference ● other files Extend Reading Material: http://git-scm.com/docs/gitrepository-layout
  • 16. Git reflog ● View the list of HEAD movement. record the Hash and action ● Log when you move reference by <commit, rebase, reset, checkout> If you get the Hash, you can recover it.
  • 17. Git fsck ● Fsck check repository integrity, find dangling commits. ● Even reflog is deleted or not record, ex: git branch -D some-branch rm -Rf .git/logs/
  • 18. Git gc ● Git do 'git gc --auto' automatically, it will ○ Pack the loose files (refs->packed-refs) ○ Delete the Non-reference files.
  • 19. Git filter-branch Filter out some commits, and do some change. ex. git filter-branch --msg-filter “echo XD” branch --Change all commit message into “XD” ex. git filter-branch --index-filter “rm xxx” branch --Delete file from git repository Extend Reading Material: http://yodalee.blogspot.tw/2014/06/git-gc.html
  • 20. Git filter-branch !filter-branch 就是要更動歷史! 在已經merge 的branch 上filter-branch會怎麼 樣? ➔ = = 建議千萬別這樣做..上次有人這樣 結果把分枝弄得一團亂.. ➔ 樓上..然後呢@@ ➔ 就把分枝弄得一團亂 很不方便..
  • 21. Git useful tool Linux: gitk, gitg https://wiki.gnome.org/Apps/Gitg/ MacOS: http://gitx.frim.nl/ Windows: X! I don’t know
  • 22. The End ● Git is POWERFUL. With basic skills, it can fulfill daily requirement. ● Hope everyone can become Git Master