SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
Git back on your Feet
February, 2016
Christian Couder
chriscool@tuxfamily.org
Git-Paris Meetup
A Distributed Version Control System (DVCS):
● created by Linus Torvalds
● maintained by Junio Hamano
● since 2005
● preferred VCS
About Git
● started developing Git in 2006
● worked especially on git bisect
● independent consultant working on Git and IPFS
● give presentations about Git since 2009
● edit Git Rev News
About myself
Git as seen by xkcd (https://xkcd.com/1597/)
Frequent Use Case
You do something and then:
● What? You're talking to me?
● Help! I don't know the current state I am in!
● I don't know WTF happened!
● I don't know how to git back on my feet!
Why “backup everything and clone again” is not a
good solution?
● You will learn nothing
● You are very likely to lose time
● You are likely to get back to the same state again
● You are likely to get frustrated
So what is the solution?
Try to answer the questions you would like to ask:
● What does the message mean?
● What is the current state?
● What happened?
● How can I git back on my feet?
What does the message mean? (1)
● Read carefully what git told you
● git help glossary, and other git help features
● Use a recent git version
● Use (LANG=fr) or don't use a localized Git (LANG=C)
● Google the message!
● Try to learn a bit about Git architecture
What does the message mean? (2)
git help demo:
● git help <cmd>
● git help glossary
● git help
● git help -a
● git help -g
● git help -w
What does the message mean? (3)
Demo git-man-page-generator:
https://git-man-page-generator.lokaltog.net/
What state I am in? (1)
Use some commands like:
● git status
● git branch, git describe
● git diff (--cached), git show
● git log, and it's very useful options:
--oneline --decorate --graph --all
What state I am in? (2)
Visualize more:
● Command line prompt
● Gitk, graphical clients (SourceTree, GitHub Desktop,...)
● git difftool and git mergetool can launch: p4merge, meld,
gvimdiff3, emerge, bc3, kdiff3, kompare, …
● Draw a diagram
Diagram example 1
commit <size>
SHA1: e84c7...
parent
tree 29c43...
author Christian <ts>
committer Christian <ts>
Initial commit
tree <size>
blob
tree
38d72...hello.c
doc 98ca9...
commit <size>
SHA1: 98ca9...
parent
tree 5c11f...
e84c7...
author Arnaud <ts>
committer Arnaud <ts>
Change hello.c
SHA1: 29c43...
tree <size>
blob
blob
677f4...readme
install 23ae9...
SHA1: 98ca9...
tree <size>
blob
tree
bc789...hello.c
doc 98ca9...
SHA1: 5c11f...
blob <size>
SHA1: 38d72...
int main() { ... }
blob <size>
SHA1: bc789...
int main(void) { ... }
Diagram example 2
What state I am in? (3)
Demos:
● git log --oneline --decorate --graph
● Merge conflict
● git mergetool
Example: merge with conflicts
● Use « git diff » and « git status » to see where are the
conflicts
● Some file will have conflicts makers inserted (<<<<<< …
====== … >>>>>>)
● Edit those files to fix conflicts and remove markers
● Use « git add » to say that conflicts are fixed
● Use « git commit » when merging or « git rebase
--continue » when rebasing
What happened? (1)
● Use your shell history
● git reflog <branch>
● ls -lrt .git/refs/heads/
● Try to replay what happened on a cloned repo or on
different branches
What happened? (2)
Demos:
● Use your shell history
● git reflog <branch>
● ls -lrt .git/refs/heads/
How can I git back on my feet? (1)
● git <cmd> --abort, e. g. git rebase --abort
● git reset, but be careful
● git checkout <file>, but be careful
● git clean (-dfx), but be very careful
● git stash, git commit, git diff, git apply (-R), be also careful
● git fsck, as a last resort
How can I git back on my feet? (2)
Five types of reset:
● --soft
● --mixed (default)
● --hard
● --merge
● --keep
How can I git back on my feet? (3)
The trick is not losing data! If possible:
● Create a branch:
git checkout -b <new_branch>
● Commit everything on this branch and push it:
git add, git commit, git push
● Go back to the previous branch:
git checkout <old_branch>
How can I git back on my feet? (4)
Demo: git reset --keep
Use case:
● git checkout master
● Hack, hack
● Git commit
● Ooops, I need to commit on a feature branch, not on
master!
● http://git-scm.com
● https://git.github.io/rev_news/archive/
● https://xkcd.com/1597/
● https://git-man-page-generator.lokaltog.net/
● https://try.github.io/
Links
Conclusion
● Git has a lot of great documentation everywhere,
but you need to be used to it
● git reset is not so difficult to understand
● It's not so difficult to quickly git back on your feet
without losing your data
Questions?

Contenu connexe

Tendances (20)

Git training
Git trainingGit training
Git training
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
SCM Boot Camp
SCM Boot CampSCM Boot Camp
SCM Boot Camp
 
Formation git
Formation gitFormation git
Formation git
 
Git: a tool for wizards
Git: a tool for wizardsGit: a tool for wizards
Git: a tool for wizards
 
Controle de versão com git
Controle de versão com gitControle de versão com git
Controle de versão com git
 
Git advanced
Git advancedGit advanced
Git advanced
 
Git in Eclipse
Git in EclipseGit in Eclipse
Git in Eclipse
 
Intro to Git
Intro to GitIntro to Git
Intro to Git
 
Workshop on Source control, git merge walkthroughs
Workshop on Source control, git merge walkthroughsWorkshop on Source control, git merge walkthroughs
Workshop on Source control, git merge walkthroughs
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git training with Devaamo
Git training with DevaamoGit training with Devaamo
Git training with Devaamo
 
Git tech talk
Git tech talkGit tech talk
Git tech talk
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 
Git
GitGit
Git
 
Corwin on containers
Corwin on containersCorwin on containers
Corwin on containers
 
Helios in Action: Git at Eclipse
Helios in Action: Git at EclipseHelios in Action: Git at Eclipse
Helios in Action: Git at Eclipse
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Git 101
Git 101Git 101
Git 101
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 

En vedette

Introduction to the PLC
Introduction to the PLCIntroduction to the PLC
Introduction to the PLCaprilme74
 
Plc (introduction and logic)
Plc (introduction and logic)Plc (introduction and logic)
Plc (introduction and logic)Mohamed A Hakim
 
Conflation Like chez Meetic par Arnaud Georgin (@arnaud_georgin - Meetic) et...
Conflation Like chez Meetic par Arnaud Georgin (@arnaud_georgin  - Meetic) et...Conflation Like chez Meetic par Arnaud Georgin (@arnaud_georgin  - Meetic) et...
Conflation Like chez Meetic par Arnaud Georgin (@arnaud_georgin - Meetic) et...Paris Scala User Group
 
Pertemuan 1. introduction to image processing
Pertemuan 1. introduction to image processingPertemuan 1. introduction to image processing
Pertemuan 1. introduction to image processingAditya Kurniawan
 
Introduction to plc programming
Introduction to plc programmingIntroduction to plc programming
Introduction to plc programmingnddng
 
01 introduction to_plc-pac_rev01_fa16
01 introduction to_plc-pac_rev01_fa1601 introduction to_plc-pac_rev01_fa16
01 introduction to_plc-pac_rev01_fa16John Todora
 
Getting started with PLCs
Getting started with PLCsGetting started with PLCs
Getting started with PLCsplc_course
 
Ladder logic fundamentals plc tutorial
Ladder logic fundamentals plc tutorialLadder logic fundamentals plc tutorial
Ladder logic fundamentals plc tutorialMavuri Malleswara Rao
 
Introduction to plc (s7)­
Introduction to  plc (s7)­ Introduction to  plc (s7)­
Introduction to plc (s7)­ majitra
 
T.L.E. GRADE 7 LESSONS
T.L.E. GRADE 7 LESSONST.L.E. GRADE 7 LESSONS
T.L.E. GRADE 7 LESSONSDayleen Hijosa
 
plc introduction
plc introduction plc introduction
plc introduction illpa
 

En vedette (20)

Play Live Coding
Play Live CodingPlay Live Coding
Play Live Coding
 
Introduction to the PLC
Introduction to the PLCIntroduction to the PLC
Introduction to the PLC
 
Plc introduction
Plc  introductionPlc  introduction
Plc introduction
 
Plc (introduction and logic)
Plc (introduction and logic)Plc (introduction and logic)
Plc (introduction and logic)
 
Introduction to PLC
Introduction to PLCIntroduction to PLC
Introduction to PLC
 
Introduction to plc
Introduction to plcIntroduction to plc
Introduction to plc
 
P L C
P L CP L C
P L C
 
Ch8 file processing
Ch8 file processingCh8 file processing
Ch8 file processing
 
Conflation Like chez Meetic par Arnaud Georgin (@arnaud_georgin - Meetic) et...
Conflation Like chez Meetic par Arnaud Georgin (@arnaud_georgin  - Meetic) et...Conflation Like chez Meetic par Arnaud Georgin (@arnaud_georgin  - Meetic) et...
Conflation Like chez Meetic par Arnaud Georgin (@arnaud_georgin - Meetic) et...
 
Pertemuan 1. introduction to image processing
Pertemuan 1. introduction to image processingPertemuan 1. introduction to image processing
Pertemuan 1. introduction to image processing
 
Introduction to plc programming
Introduction to plc programmingIntroduction to plc programming
Introduction to plc programming
 
Chapter 2 ladder
Chapter 2 ladderChapter 2 ladder
Chapter 2 ladder
 
01 introduction to_plc-pac_rev01_fa16
01 introduction to_plc-pac_rev01_fa1601 introduction to_plc-pac_rev01_fa16
01 introduction to_plc-pac_rev01_fa16
 
Read and Understand The Electrical Diagram
Read and Understand The Electrical DiagramRead and Understand The Electrical Diagram
Read and Understand The Electrical Diagram
 
Getting started with PLCs
Getting started with PLCsGetting started with PLCs
Getting started with PLCs
 
Ladder logic fundamentals plc tutorial
Ladder logic fundamentals plc tutorialLadder logic fundamentals plc tutorial
Ladder logic fundamentals plc tutorial
 
Introduction to plc (s7)­
Introduction to  plc (s7)­ Introduction to  plc (s7)­
Introduction to plc (s7)­
 
T.L.E. GRADE 7 LESSONS
T.L.E. GRADE 7 LESSONST.L.E. GRADE 7 LESSONS
T.L.E. GRADE 7 LESSONS
 
Omron ladder programming
Omron ladder programmingOmron ladder programming
Omron ladder programming
 
plc introduction
plc introduction plc introduction
plc introduction
 

Similaire à Git back on_your_feet

Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
HandsOn: git (or version control in general...)
HandsOn: git (or version control in general...)HandsOn: git (or version control in general...)
HandsOn: git (or version control in general...)Martin Scharm
 
Git Basics 1 Carenza
Git Basics 1 CarenzaGit Basics 1 Carenza
Git Basics 1 CarenzaPeter Carenza
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitAmit Mathur
 
Git with the flow
Git with the flowGit with the flow
Git with the flowDana White
 
How to git easily in day to-day work
How to git easily in day to-day workHow to git easily in day to-day work
How to git easily in day to-day workAlena Radkevich
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How tolanhuonga3
 
Git slides
Git slidesGit slides
Git slides55020
 
Git for beginners
Git for beginnersGit for beginners
Git for beginnersAndy Slocum
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introductionrschwietzke
 
Git - Some tips to do it better
Git - Some tips to do it betterGit - Some tips to do it better
Git - Some tips to do it betterJonas De Smet
 

Similaire à Git back on_your_feet (20)

Git of every day
Git of every dayGit of every day
Git of every day
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
HandsOn: git (or version control in general...)
HandsOn: git (or version control in general...)HandsOn: git (or version control in general...)
HandsOn: git (or version control in general...)
 
Git Basics 1 Carenza
Git Basics 1 CarenzaGit Basics 1 Carenza
Git Basics 1 Carenza
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git with the flow
Git with the flowGit with the flow
Git with the flow
 
How to git easily in day to-day work
How to git easily in day to-day workHow to git easily in day to-day work
How to git easily in day to-day work
 
Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Git slides
Git slidesGit slides
Git slides
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Now i git it!!!
Now i git it!!!Now i git it!!!
Now i git it!!!
 
Git basics
Git basicsGit basics
Git basics
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git: be social
Git: be socialGit: be social
Git: be social
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
 
Git - Some tips to do it better
Git - Some tips to do it betterGit - Some tips to do it better
Git - Some tips to do it better
 

Dernier

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Dernier (20)

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Git back on_your_feet

  • 1. Git back on your Feet February, 2016 Christian Couder chriscool@tuxfamily.org Git-Paris Meetup
  • 2. A Distributed Version Control System (DVCS): ● created by Linus Torvalds ● maintained by Junio Hamano ● since 2005 ● preferred VCS About Git
  • 3. ● started developing Git in 2006 ● worked especially on git bisect ● independent consultant working on Git and IPFS ● give presentations about Git since 2009 ● edit Git Rev News About myself
  • 4. Git as seen by xkcd (https://xkcd.com/1597/)
  • 5. Frequent Use Case You do something and then: ● What? You're talking to me? ● Help! I don't know the current state I am in! ● I don't know WTF happened! ● I don't know how to git back on my feet!
  • 6. Why “backup everything and clone again” is not a good solution? ● You will learn nothing ● You are very likely to lose time ● You are likely to get back to the same state again ● You are likely to get frustrated
  • 7. So what is the solution? Try to answer the questions you would like to ask: ● What does the message mean? ● What is the current state? ● What happened? ● How can I git back on my feet?
  • 8. What does the message mean? (1) ● Read carefully what git told you ● git help glossary, and other git help features ● Use a recent git version ● Use (LANG=fr) or don't use a localized Git (LANG=C) ● Google the message! ● Try to learn a bit about Git architecture
  • 9. What does the message mean? (2) git help demo: ● git help <cmd> ● git help glossary ● git help ● git help -a ● git help -g ● git help -w
  • 10. What does the message mean? (3) Demo git-man-page-generator: https://git-man-page-generator.lokaltog.net/
  • 11. What state I am in? (1) Use some commands like: ● git status ● git branch, git describe ● git diff (--cached), git show ● git log, and it's very useful options: --oneline --decorate --graph --all
  • 12. What state I am in? (2) Visualize more: ● Command line prompt ● Gitk, graphical clients (SourceTree, GitHub Desktop,...) ● git difftool and git mergetool can launch: p4merge, meld, gvimdiff3, emerge, bc3, kdiff3, kompare, … ● Draw a diagram
  • 13. Diagram example 1 commit <size> SHA1: e84c7... parent tree 29c43... author Christian <ts> committer Christian <ts> Initial commit tree <size> blob tree 38d72...hello.c doc 98ca9... commit <size> SHA1: 98ca9... parent tree 5c11f... e84c7... author Arnaud <ts> committer Arnaud <ts> Change hello.c SHA1: 29c43... tree <size> blob blob 677f4...readme install 23ae9... SHA1: 98ca9... tree <size> blob tree bc789...hello.c doc 98ca9... SHA1: 5c11f... blob <size> SHA1: 38d72... int main() { ... } blob <size> SHA1: bc789... int main(void) { ... }
  • 15. What state I am in? (3) Demos: ● git log --oneline --decorate --graph ● Merge conflict ● git mergetool
  • 16. Example: merge with conflicts ● Use « git diff » and « git status » to see where are the conflicts ● Some file will have conflicts makers inserted (<<<<<< … ====== … >>>>>>) ● Edit those files to fix conflicts and remove markers ● Use « git add » to say that conflicts are fixed ● Use « git commit » when merging or « git rebase --continue » when rebasing
  • 17. What happened? (1) ● Use your shell history ● git reflog <branch> ● ls -lrt .git/refs/heads/ ● Try to replay what happened on a cloned repo or on different branches
  • 18. What happened? (2) Demos: ● Use your shell history ● git reflog <branch> ● ls -lrt .git/refs/heads/
  • 19. How can I git back on my feet? (1) ● git <cmd> --abort, e. g. git rebase --abort ● git reset, but be careful ● git checkout <file>, but be careful ● git clean (-dfx), but be very careful ● git stash, git commit, git diff, git apply (-R), be also careful ● git fsck, as a last resort
  • 20. How can I git back on my feet? (2) Five types of reset: ● --soft ● --mixed (default) ● --hard ● --merge ● --keep
  • 21. How can I git back on my feet? (3) The trick is not losing data! If possible: ● Create a branch: git checkout -b <new_branch> ● Commit everything on this branch and push it: git add, git commit, git push ● Go back to the previous branch: git checkout <old_branch>
  • 22. How can I git back on my feet? (4) Demo: git reset --keep Use case: ● git checkout master ● Hack, hack ● Git commit ● Ooops, I need to commit on a feature branch, not on master!
  • 23. ● http://git-scm.com ● https://git.github.io/rev_news/archive/ ● https://xkcd.com/1597/ ● https://git-man-page-generator.lokaltog.net/ ● https://try.github.io/ Links
  • 24. Conclusion ● Git has a lot of great documentation everywhere, but you need to be used to it ● git reset is not so difficult to understand ● It's not so difficult to quickly git back on your feet without losing your data