SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
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?

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Kürzlich hochgeladen (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

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