SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
Git Tutorial II 
Jim Yeh
Outline 
• Review 
• Collaboration 
• Merge 
• Rebase 
• Simple GUI Demo 
• Working on GitHub
Review
Commands (I) 
• git clone <repository> 
• git status 
• git log 
• git diff
Commands (II) 
• git add <files> 
• git commit 
• git branch <branch> 
• git checkout <branch> 
• git pull <remote> <branch> 
• git push <remote> <branch>
Commit Cycle 
• Update file 
(Open the file and update its content manually) 
• git add 
• git commit
Collaboration
Methods 
• Merge 
• Rebase
Merge 
• A common option 
• A complicated branch (tree)
Fetch & Pull 
• git fetch - Update remote branches 
• git pull - Update remote branches and current branch
Merge Cycle 
• Checkout master 
• Pull 
• Merge 
• Push 
Initial
Merge Cycle 
• Checkout master 
• Pull 
• Merge 
• Push 
Initial 
Your branch
Merge Cycle 
• Checkout master 
• Pull 
• Merge 
• Push 
After Pull Your branch 
Initial
Merge Cycle 
• Checkout master 
• Pull 
• Merge 
• Push 
After Pull Your branch 
Initial 
Merge
Merge Cycle 
• Checkout master 
• Pull 
• Merge 
• Push 
After Pull Your branch 
Initial 
Merge 
Remote 
Push
Merge Cycle 
After Pull Your branch 
Initial 
Merge 
Remote 
Push 
• git checkout master 
• git pull 
• git merge <your branch> 
• git push origin master
Conflict!
Fix conflict 
• Find the conflict part and fix them: 
<<<<<<< HEAD 
Original contents 
======= 
New contents 
>>>>>>> test_merge 
• Add updated files 
• Commit
git log --graph
Push failed 
Try: git pull
Exercise 5 
• Add your introduction at the bottom of introduction.txt 
• Checkout master 
• Pull 
• git merge <your branch> 
• Fix conflict 
• Push
Exercise 5 
• Add your introduction at the bottom of introduction.txt 
• git checkout master 
• git pull 
• git merge <your branch> 
• Fix conflict 
• git push origin master
Git Stash 
• Stock your local difference (A queue) 
• Prevent conflict on git pull 
• Make branch be clean
Git Stash 
• git stash 
• git stash list 
• git stash pop 
• git stash drop
Rebase 
• Trees are clean 
• Work on single branch 
• Each commit will be recreated. 
That is, the commit number and timestamp will change.
Rebase 
• git pull --rebase
Rebase Flow 
• git commit 
• git pull --rebase 
• Fix conflict 
• git add <fixed filename> 
• git rebase --continue 
• git push
Exercise 6 
• Checkout master branch 
• Add your student id into ids file 
• Commit 
• Pull by rebase and fix conflict if necessary 
(git pull --rebase) 
• Push
Merge / Rebase 
• Choose the one you preferred. 
• Merge is the default option. 
• Rebase is more clean.
Git GUI Client 
• GitHub 
• SourceTree
Working on GitHub 
• Fork 
• Pull Request
Fork / Pull Request 
Fork 
Someone’s Repo A cloned Repo 
Update / Commit / Push 
New commit in 
Merge 
Pull request your Repo 
Pull request
Exercise 7 
• Fork git-exercise-2 
• Create files for comments to this session 
• Commit / Push 
• Pull request
Q & A

Weitere ähnliche Inhalte

Was ist angesagt?

Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 

Was ist angesagt? (20)

Git tutorial
Git tutorial Git tutorial
Git tutorial
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git 101
Git 101Git 101
Git 101
 
Learning git
Learning gitLearning git
Learning git
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git basics
Git basicsGit basics
Git basics
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
Introduction to git & GitHub
Introduction to git & GitHubIntroduction to git & GitHub
Introduction to git & GitHub
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Intro to Git, GitHub, and Devpost
Intro to Git, GitHub, and DevpostIntro to Git, GitHub, and Devpost
Intro to Git, GitHub, and Devpost
 
git and github
git and githubgit and github
git and github
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
GIT presentation
GIT presentationGIT presentation
GIT presentation
 

Andere mochten auch

Intégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec JenkinsIntégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec Jenkins
Hugo Hamon
 
Intégration continue & Qualité logicielle
Intégration continue & Qualité logicielleIntégration continue & Qualité logicielle
Intégration continue & Qualité logicielle
David Buros
 

Andere mochten auch (20)

Intégration Continue PHP avec Jenkins CI
Intégration Continue PHP avec Jenkins CIIntégration Continue PHP avec Jenkins CI
Intégration Continue PHP avec Jenkins CI
 
Intégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec JenkinsIntégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec Jenkins
 
Cours php
Cours phpCours php
Cours php
 
Php4 Mysql
Php4 MysqlPhp4 Mysql
Php4 Mysql
 
intro unix/linux 05
intro unix/linux 05intro unix/linux 05
intro unix/linux 05
 
Introduction à WordPress sous Nginx
Introduction à WordPress sous NginxIntroduction à WordPress sous Nginx
Introduction à WordPress sous Nginx
 
Présentation de git
Présentation de gitPrésentation de git
Présentation de git
 
Jenkins Workflow
Jenkins WorkflowJenkins Workflow
Jenkins Workflow
 
Emacs presentation
Emacs presentationEmacs presentation
Emacs presentation
 
Jenkins - Les jeudis de la découverte
Jenkins - Les jeudis de la découverteJenkins - Les jeudis de la découverte
Jenkins - Les jeudis de la découverte
 
JENKINS_BreizhJUG_20111003
JENKINS_BreizhJUG_20111003JENKINS_BreizhJUG_20111003
JENKINS_BreizhJUG_20111003
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internals
 
Grep - A powerful search utility
Grep - A powerful search utilityGrep - A powerful search utility
Grep - A powerful search utility
 
Cours php & Mysql - 4éme partie
Cours php & Mysql - 4éme partieCours php & Mysql - 4éme partie
Cours php & Mysql - 4éme partie
 
Intégration continue & Qualité logicielle
Intégration continue & Qualité logicielleIntégration continue & Qualité logicielle
Intégration continue & Qualité logicielle
 
Cours php & Mysql - 5éme partie
Cours php & Mysql - 5éme partieCours php & Mysql - 5éme partie
Cours php & Mysql - 5éme partie
 
Cours php & Mysql - 3éme partie
Cours php & Mysql - 3éme partieCours php & Mysql - 3éme partie
Cours php & Mysql - 3éme partie
 
Cours php & Mysql - 2éme partie
Cours php & Mysql - 2éme partieCours php & Mysql - 2éme partie
Cours php & Mysql - 2éme partie
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
 
Cheatsheet: Hex file headers and regex
Cheatsheet: Hex file headers and regexCheatsheet: Hex file headers and regex
Cheatsheet: Hex file headers and regex
 

Ähnlich wie Git tutorial II

Ähnlich wie Git tutorial II (20)

Git training v10
Git training v10Git training v10
Git training v10
 
Git workshop - University of Moratuwa, Department of Computer Science and Eng...
Git workshop - University of Moratuwa, Department of Computer Science and Eng...Git workshop - University of Moratuwa, Department of Computer Science and Eng...
Git workshop - University of Moratuwa, Department of Computer Science and Eng...
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
 
Introduction into Git
Introduction into GitIntroduction into Git
Introduction into Git
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
11 git version control
11 git version control11 git version control
11 git version control
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Git简介
Git简介Git简介
Git简介
 
COSCUP 開源工作坊:Git workflows
COSCUP 開源工作坊:Git workflowsCOSCUP 開源工作坊:Git workflows
COSCUP 開源工作坊:Git workflows
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
 
Git Ninja KT (GitHub to GitLab)
Git Ninja KT (GitHub to GitLab)Git Ninja KT (GitHub to GitLab)
Git Ninja KT (GitHub to GitLab)
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
 
Learn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsLearn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levels
 
Talk to git
Talk to gitTalk to git
Talk to git
 
Git Workflow
Git WorkflowGit Workflow
Git Workflow
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Git tutorial II

  • 1. Git Tutorial II Jim Yeh
  • 2. Outline • Review • Collaboration • Merge • Rebase • Simple GUI Demo • Working on GitHub
  • 4. Commands (I) • git clone <repository> • git status • git log • git diff
  • 5. Commands (II) • git add <files> • git commit • git branch <branch> • git checkout <branch> • git pull <remote> <branch> • git push <remote> <branch>
  • 6. Commit Cycle • Update file (Open the file and update its content manually) • git add • git commit
  • 8. Methods • Merge • Rebase
  • 9. Merge • A common option • A complicated branch (tree)
  • 10. Fetch & Pull • git fetch - Update remote branches • git pull - Update remote branches and current branch
  • 11. Merge Cycle • Checkout master • Pull • Merge • Push Initial
  • 12. Merge Cycle • Checkout master • Pull • Merge • Push Initial Your branch
  • 13. Merge Cycle • Checkout master • Pull • Merge • Push After Pull Your branch Initial
  • 14. Merge Cycle • Checkout master • Pull • Merge • Push After Pull Your branch Initial Merge
  • 15. Merge Cycle • Checkout master • Pull • Merge • Push After Pull Your branch Initial Merge Remote Push
  • 16. Merge Cycle After Pull Your branch Initial Merge Remote Push • git checkout master • git pull • git merge <your branch> • git push origin master
  • 18. Fix conflict • Find the conflict part and fix them: <<<<<<< HEAD Original contents ======= New contents >>>>>>> test_merge • Add updated files • Commit
  • 20. Push failed Try: git pull
  • 21. Exercise 5 • Add your introduction at the bottom of introduction.txt • Checkout master • Pull • git merge <your branch> • Fix conflict • Push
  • 22. Exercise 5 • Add your introduction at the bottom of introduction.txt • git checkout master • git pull • git merge <your branch> • Fix conflict • git push origin master
  • 23. Git Stash • Stock your local difference (A queue) • Prevent conflict on git pull • Make branch be clean
  • 24. Git Stash • git stash • git stash list • git stash pop • git stash drop
  • 25. Rebase • Trees are clean • Work on single branch • Each commit will be recreated. That is, the commit number and timestamp will change.
  • 26. Rebase • git pull --rebase
  • 27. Rebase Flow • git commit • git pull --rebase • Fix conflict • git add <fixed filename> • git rebase --continue • git push
  • 28. Exercise 6 • Checkout master branch • Add your student id into ids file • Commit • Pull by rebase and fix conflict if necessary (git pull --rebase) • Push
  • 29. Merge / Rebase • Choose the one you preferred. • Merge is the default option. • Rebase is more clean.
  • 30. Git GUI Client • GitHub • SourceTree
  • 31. Working on GitHub • Fork • Pull Request
  • 32. Fork / Pull Request Fork Someone’s Repo A cloned Repo Update / Commit / Push New commit in Merge Pull request your Repo Pull request
  • 33. Exercise 7 • Fork git-exercise-2 • Create files for comments to this session • Commit / Push • Pull request
  • 34. Q & A