SlideShare a Scribd company logo
A Tutorial for Git and
GitHub
Xiao Li
Department of Informatics
University of Zurich
Agenda
 Why use Version (Source) Control Systems
 What are Git and GitHub
 Basic Git Commands
 Fundamentals of GitHub
 Using GitHub in Project Implementation
3
Why version control?
 Scenario 1:
Your program is working
You change “just one thing”
Your program breaks
You change it back
Your program is still broken--why?
 Has this ever happened to you?
4
Why version control? (part 2)
 Your program worked well enough yesterday
 You made a lot of improvements last night...
...but you haven't gotten them to work yet
 You need to turn in your program now
 Has this ever happened to you?
5
Version control for teams
 Scenario:
You change one part of a program--it works
Your co-worker changes another part--it works
You put them together--it doesn’t work
Some change in one part must have broken something in the
other part
What were all the changes?
6
Teams (part 2)
 Scenario:
You make a number of improvements to a
class
Your co-worker makes a number of different
improvements to the same class
 How can you merge these changes?
7
Version control systems
 A version control system (often called a source code
control system) does these things:
Keeps multiple (older and newer) versions of everything (not
just source code)
Requests comments regarding every change
Allows “check in” and “check out” of files so you know which
files someone else is working on
Displays differences between versions
Benefits of version control
 For working by yourself:
Gives you a “time machine” for going back to earlier versions
Gives you great support for different versions (standalone, web
app, etc.) of the same basic project
 For working with others:
Greatly simplifies concurrent work, merging changes
8
What are Git and GitHub
 Git is a free and open source distributed version control
system designed to handle everything from small to very
large projects with speed and efficiency
 GitHub is a web-based Git repository hosting service,
which offers all of the distributed revision control and
source code management (SCM) functionality of Git as
well as adding its own features.
How to setup Git and GitHub
 Download and install the latest version of GitHub
Desktop. This will automatically install Git and keep it up-
to-date for you.
 https://help.github.com/articles/set-up-git/
BASIC GIT COMMANDS
Introduce yourself to Git
 On your computer, open the Git Shell application.
 Enter these lines (with appropriate changes):
 git config --global user.name "John Smith"
 git config --global user.email jsmith@seas.upenn.edu
 You only need to do this once
 If you want to use a different name/email address for a
particular project, you can change it for just that project
cd to the project directory
Use the above commands, but leave out the --global
12
The repository
 Your top-level working directory contains everything about your project
 The working directory probably contains many subdirectories—source code, binaries,
documentation, data files, etc.
 One of these subdirectories, named .git, is your repository
 At any time, you can take a “snapshot” of everything (or selected things) in
your project directory, and put it in your repository
 This “snapshot” is called a commit object
 The commit object contains (1) a set of files, (2) references to the “parents” of the commit
object, and (3) a unique “SHA1” name
 Commit objects do not require huge amounts of memory
 You can work as much as you like in your working directory, but the
repository isn’t updated until you commit something
13
init and the .git repository
 When you said git init in your project directory, or
when you cloned an existing project, you created a
repository
The repository is a subdirectory named .git containing various
files
The dot indicates a “hidden” directory
You do not work directly with the contents of that directory;
various git commands do that for you
14
Making commits
 You do your work in your project directory, as usual
 If you create new files and/or folders, they are not tracked by Git unless you ask it to do so
 git add newFile1 newFolder1 newFolder2 newFile2
 Committing makes a “snapshot” of everything being tracked into your repository
 A message telling what you have done is required
 git commit –m “Uncrevulated the conundrum bar”
 git commit
 This version opens an editor for you the enter the message
 To finish, save and quit the editor
 Format of the commit message
 One line containing the complete summary
 If more than one line, the second line must be blank
15
Commits and graphs
 A commit is when you tell git that a change (or addition) you have made is
ready to be included in the project
 When you commit your change to git, it creates a commit object
 A commit object represents the complete state of the project, including all the files in
the project
 The very first commit object has no “parents”
 Usually, you take some commit object, make some changes, and create a new commit
object; the original commit object is the parent of the new commit object
 Hence, most commit objects have a single parent
 You can also merge two commit objects to form a new one
 The new commit object has two parents
 Hence, commit objects forms a directed graph
 Git is all about using and manipulating this graph
16
Commit messages
 In git, “Commits are cheap.” Do them often.
 When you commit, you must provide a one-line message
stating what you have done
Terrible message: “Fixed a bunch of things”
Better message: “Corrected the calculation of median scores”
 Commit messages can be very helpful, to yourself as well
as to your team members
 You can’t say much in one line, so commit often
17
Typical workflow
 git status
See what Git thinks is going on
Use this frequently!
 Work on your files
 git add your editfiles
 git commit –m “What I did”
18
Keeping it simple
 If you:
 Make sure you are current with the central repository
 Make some improvements to your code
 Update the central repository before anyone else does
 Then you don’t have to worry about resolving conflicts or working
with multiple branches
 All the complexity in git comes from dealing with these
 Therefore:
 Make sure you are up-to-date before starting to work
 Commit and update the central repository frequently
 If you need help: https://help.github.com/
19
More Commands: Don’t Get Scared.
GitHub Desktop can Help You
FUNDAMENTALS OF GITHUB
Introduce yourself to GitHub
 Register on GitHub
https://github.com/
 Authenticating to GitHub Desktop
https://help.github.com/desktop/guides/getting-
started/authenticating-to-github/
 Configuring Git for GitHub Desktop
https://help.github.com/desktop/guides/getting-
started/configuring-git-for-github-desktop/
Create or add a repository to GitHub
 Create a new repository on GitHub
https://help.github.com/articles/create-a-repo/
 From GitHub Desktop, then Publish to GitHub
https://help.github.com/desktop/guides/contributing/adding-a-
repository-from-your-local-computer-to-github-desktop/
Remember to Publish, otherwise your repository would not
appear on the GitHub website.
Commit your changes on GitHub
 From GitHub Website
https://help.github.com/articles/create-a-repo/
 From GitHub Desktop
https://help.github.com/desktop/guides/contributing/committing-
and-reviewing-changes-to-your-project/
Creating a branch for your work
 A branch is a parallel version of the main line of
development in the repository, or the default branch
(usually master). Use branches to
 Develop features
 Fix bugs
 Safely experiment with new ideas
 From the GitHub Website
 https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
 From the GitHub Desktop
 https://help.github.com/desktop/guides/contributing/creating-a-branch-for-your-work/
Synchronizing your branch
 As commits are pushed to your project on GitHub, you
can keep your local copy of the project in sync with the
remote repository.
https://help.github.com/desktop/guides/contributing/syncing-
your-branch/
Viewing the history of your commits
 When you click a commit on the commit timeline, you can
see more details about the commit, including a diff of the
changes the commit introduced.
 Each commit shows:
The commit message
The time the commit was created
The committer's username and profile photo (if available)
The commit's SHA-1 hash (the unique ID)
Revert your commit
 If you change your mind about a commit after you create
it, you can revert the commit.
 When you revert to a previous commit, the revert is also a
commit. In addition, the original commit remains in the
repository's history.
 https://help.github.com/desktop/guides/contributing/reverti
ng-a-commit/
Fork & Pull: A Collaborative model
 A fork is a copy of a repository that you manage. Forks let
you make changes to a project without affecting the
original repository. You can fetch updates from or submit
changes to the original repository with pull requests.
 A great example of using forks to propose changes is for
bug fixes. Rather than logging an issue for a bug you've
found, you can:
Fork the repository.
Make the fix.
Submit a pull request to the project owner.
Using GitHub in Project Implementation
In the section of project implementation in your project
report, you may describe:
 How you use GitHub in your project
 How version control helps your quality management
 How you collaborate with your teammate in GitHub
References
Some content of the slides are adapted from:
 https://help.github.com/desktop/guides/getting-started/
 https://help.github.com/desktop/guides/contributing/
 https://help.github.com/categories/collaborating/
 http://www.cis.upenn.edu/~matuszek/cit591-
2012/Lectures/git.ppt
Ad

More Related Content

What's hot (20)

Git,Github,How to host using Github
Git,Github,How to host using GithubGit,Github,How to host using Github
Git,Github,How to host using Github
Sujata Regoti
 
Git basics
Git basicsGit basics
Git basics
GHARSALLAH Mohamed
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
Krunal Doshi
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
HubSpot
 
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
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
Dilum Navanjana
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
Sourabh Sahu
 
Jenkins vs GitLab CI
Jenkins vs GitLab CIJenkins vs GitLab CI
Jenkins vs GitLab CI
CEE-SEC(R)
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Lukas Fittl
 
Jenkins-CI
Jenkins-CIJenkins-CI
Jenkins-CI
Gong Haibing
 
Meetup 23 - 03 - Application Delivery on K8S with GitOps
Meetup 23 - 03 - Application Delivery on K8S with GitOpsMeetup 23 - 03 - Application Delivery on K8S with GitOps
Meetup 23 - 03 - Application Delivery on K8S with GitOps
Vietnam Open Infrastructure User Group
 
Belajar Dasar-Dasar GIT
Belajar Dasar-Dasar GITBelajar Dasar-Dasar GIT
Belajar Dasar-Dasar GIT
Aristyo Hadikusuma
 
Using Qt under LGPLv3
Using Qt under LGPLv3Using Qt under LGPLv3
Using Qt under LGPLv3
Burkhard Stubert
 
Improving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesImproving app performance with Kotlin Coroutines
Improving app performance with Kotlin Coroutines
Hassan Abid
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
nishantsri
 
What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020
Noa Harel
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
Jiwon Baek
 
GitOps: Git come unica fonte di verità per applicazioni e infrastruttura
GitOps: Git come unica fonte di verità per applicazioni e infrastrutturaGitOps: Git come unica fonte di verità per applicazioni e infrastruttura
GitOps: Git come unica fonte di verità per applicazioni e infrastruttura
sparkfabrik
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
Bioinformatics and Computational Biosciences Branch
 
Git,Github,How to host using Github
Git,Github,How to host using GithubGit,Github,How to host using Github
Git,Github,How to host using Github
Sujata Regoti
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
Krunal Doshi
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
HubSpot
 
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
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
Dilum Navanjana
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
Sourabh Sahu
 
Jenkins vs GitLab CI
Jenkins vs GitLab CIJenkins vs GitLab CI
Jenkins vs GitLab CI
CEE-SEC(R)
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Lukas Fittl
 
Improving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesImproving app performance with Kotlin Coroutines
Improving app performance with Kotlin Coroutines
Hassan Abid
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
nishantsri
 
What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020
Noa Harel
 
GitOps: Git come unica fonte di verità per applicazioni e infrastruttura
GitOps: Git come unica fonte di verità per applicazioni e infrastrutturaGitOps: Git come unica fonte di verità per applicazioni e infrastruttura
GitOps: Git come unica fonte di verità per applicazioni e infrastruttura
sparkfabrik
 

Similar to A Tutorial for GitHub.pdf (20)

git.ppt
git.pptgit.ppt
git.ppt
ssuser10dcd71
 
Git
GitGit
Git
zafarfaizi
 
Git
GitGit
Git
Alf Chang
 
Git
GitGit
Git
Vijay Kani
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptx
Hitesh670643
 
16 Git
16 Git16 Git
16 Git
Hadley Wickham
 
Beginner Workshop for Student Developers - Tratech-presentation.pdf
Beginner Workshop for Student Developers - Tratech-presentation.pdfBeginner Workshop for Student Developers - Tratech-presentation.pdf
Beginner Workshop for Student Developers - Tratech-presentation.pdf
GDSCKNUST
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
"FENG "GEORGE"" YU
 
Getting started With GIT
Getting started With GITGetting started With GIT
Getting started With GIT
GhadiAlGhosh
 
Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git
John Tighe
 
A prentation on github
A prentation on githubA prentation on github
A prentation on github
Veronica Ojochona Michael (MCP)
 
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
Himanshu Agrawal
 
Git Hub Platform
Git Hub PlatformGit Hub Platform
Git Hub Platform
Gaurav Ahluwalia
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
Naveen Pandey
 
Advance workshop on git
Advance workshop on gitAdvance workshop on git
Advance workshop on git
Himanshu Agrawal
 
GIT & Github introduction for beginners
GIT & Github introduction for  beginnersGIT & Github introduction for  beginners
GIT & Github introduction for beginners
riteshsingh3651
 
Git Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdfGit Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdf
uzair
 
Intro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucketIntro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucket
Legal Services National Technology Assistance Project (LSNTAP)
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1
Omar Fathy
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
ssusered2ec2
 
Ad

More from badrfathallah2 (19)

Java-Design-Patterns.pdf
Java-Design-Patterns.pdfJava-Design-Patterns.pdf
Java-Design-Patterns.pdf
badrfathallah2
 
design_pattern_tutorial.pdf
design_pattern_tutorial.pdfdesign_pattern_tutorial.pdf
design_pattern_tutorial.pdf
badrfathallah2
 
Octo Maven.pdf
Octo Maven.pdfOcto Maven.pdf
Octo Maven.pdf
badrfathallah2
 
hibernate_tutorial.pdf
hibernate_tutorial.pdfhibernate_tutorial.pdf
hibernate_tutorial.pdf
badrfathallah2
 
Les Processus IAM.pdf
Les Processus IAM.pdfLes Processus IAM.pdf
Les Processus IAM.pdf
badrfathallah2
 
LE PROCESSUS DE GESTION DES HABILITATIONS.pdf
LE PROCESSUS DE GESTION DES HABILITATIONS.pdfLE PROCESSUS DE GESTION DES HABILITATIONS.pdf
LE PROCESSUS DE GESTION DES HABILITATIONS.pdf
badrfathallah2
 
PrésQL.pdf
PrésQL.pdfPrésQL.pdf
PrésQL.pdf
badrfathallah2
 
INTRODUCTION A LA FINANCE DE MARCHE.pdf
INTRODUCTION A LA FINANCE DE MARCHE.pdfINTRODUCTION A LA FINANCE DE MARCHE.pdf
INTRODUCTION A LA FINANCE DE MARCHE.pdf
badrfathallah2
 
Collatéral_Management.pdf
Collatéral_Management.pdfCollatéral_Management.pdf
Collatéral_Management.pdf
badrfathallah2
 
Cash_management_et_paiements.pdf
Cash_management_et_paiements.pdfCash_management_et_paiements.pdf
Cash_management_et_paiements.pdf
badrfathallah2
 
Scrumguide.pdf
Scrumguide.pdfScrumguide.pdf
Scrumguide.pdf
badrfathallah2
 
Gestion de projets agiles avec Scrum.pdf
Gestion de projets agiles avec Scrum.pdfGestion de projets agiles avec Scrum.pdf
Gestion de projets agiles avec Scrum.pdf
badrfathallah2
 
tp-spring.pdf
tp-spring.pdftp-spring.pdf
tp-spring.pdf
badrfathallah2
 
Introduction à Spring.pdf
Introduction à Spring.pdfIntroduction à Spring.pdf
Introduction à Spring.pdf
badrfathallah2
 
SVN Tutorial.pdf
SVN Tutorial.pdfSVN Tutorial.pdf
SVN Tutorial.pdf
badrfathallah2
 
La Gestion de Projet.pdf
La Gestion de Projet.pdfLa Gestion de Projet.pdf
La Gestion de Projet.pdf
badrfathallah2
 
Introduction à git.pdf
Introduction à git.pdfIntroduction à git.pdf
Introduction à git.pdf
badrfathallah2
 
JIRA-Tutorial-pdf.pdf
JIRA-Tutorial-pdf.pdfJIRA-Tutorial-pdf.pdf
JIRA-Tutorial-pdf.pdf
badrfathallah2
 
JIRA Fundamentals Course.pdf
JIRA Fundamentals Course.pdfJIRA Fundamentals Course.pdf
JIRA Fundamentals Course.pdf
badrfathallah2
 
Java-Design-Patterns.pdf
Java-Design-Patterns.pdfJava-Design-Patterns.pdf
Java-Design-Patterns.pdf
badrfathallah2
 
design_pattern_tutorial.pdf
design_pattern_tutorial.pdfdesign_pattern_tutorial.pdf
design_pattern_tutorial.pdf
badrfathallah2
 
hibernate_tutorial.pdf
hibernate_tutorial.pdfhibernate_tutorial.pdf
hibernate_tutorial.pdf
badrfathallah2
 
LE PROCESSUS DE GESTION DES HABILITATIONS.pdf
LE PROCESSUS DE GESTION DES HABILITATIONS.pdfLE PROCESSUS DE GESTION DES HABILITATIONS.pdf
LE PROCESSUS DE GESTION DES HABILITATIONS.pdf
badrfathallah2
 
INTRODUCTION A LA FINANCE DE MARCHE.pdf
INTRODUCTION A LA FINANCE DE MARCHE.pdfINTRODUCTION A LA FINANCE DE MARCHE.pdf
INTRODUCTION A LA FINANCE DE MARCHE.pdf
badrfathallah2
 
Collatéral_Management.pdf
Collatéral_Management.pdfCollatéral_Management.pdf
Collatéral_Management.pdf
badrfathallah2
 
Cash_management_et_paiements.pdf
Cash_management_et_paiements.pdfCash_management_et_paiements.pdf
Cash_management_et_paiements.pdf
badrfathallah2
 
Gestion de projets agiles avec Scrum.pdf
Gestion de projets agiles avec Scrum.pdfGestion de projets agiles avec Scrum.pdf
Gestion de projets agiles avec Scrum.pdf
badrfathallah2
 
Introduction à Spring.pdf
Introduction à Spring.pdfIntroduction à Spring.pdf
Introduction à Spring.pdf
badrfathallah2
 
La Gestion de Projet.pdf
La Gestion de Projet.pdfLa Gestion de Projet.pdf
La Gestion de Projet.pdf
badrfathallah2
 
Introduction à git.pdf
Introduction à git.pdfIntroduction à git.pdf
Introduction à git.pdf
badrfathallah2
 
JIRA Fundamentals Course.pdf
JIRA Fundamentals Course.pdfJIRA Fundamentals Course.pdf
JIRA Fundamentals Course.pdf
badrfathallah2
 
Ad

Recently uploaded (20)

Explainable-Artificial-Intelligence-in-Disaster-Risk-Management (2).pptx_2024...
Explainable-Artificial-Intelligence-in-Disaster-Risk-Management (2).pptx_2024...Explainable-Artificial-Intelligence-in-Disaster-Risk-Management (2).pptx_2024...
Explainable-Artificial-Intelligence-in-Disaster-Risk-Management (2).pptx_2024...
LiyaShaji4
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
Unit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatioUnit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatio
lakshitakumar291
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
"Heaters in Power Plants: Types, Functions, and Performance Analysis"
"Heaters in Power Plants: Types, Functions, and Performance Analysis""Heaters in Power Plants: Types, Functions, and Performance Analysis"
"Heaters in Power Plants: Types, Functions, and Performance Analysis"
Infopitaara
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
Engineering Chemistry First Year Fullerenes
Engineering Chemistry First Year FullerenesEngineering Chemistry First Year Fullerenes
Engineering Chemistry First Year Fullerenes
5g2jpd9sp4
 
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Journal of Soft Computing in Civil Engineering
 
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.
Kamal Acharya
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
How to Make Material Space Qu___ (1).pptx
How to Make Material Space Qu___ (1).pptxHow to Make Material Space Qu___ (1).pptx
How to Make Material Space Qu___ (1).pptx
engaash9
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
comparison of motors.pptx 1. Motor Terminology.ppt
comparison of motors.pptx 1. Motor Terminology.pptcomparison of motors.pptx 1. Motor Terminology.ppt
comparison of motors.pptx 1. Motor Terminology.ppt
yadavmrr7
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Explainable-Artificial-Intelligence-in-Disaster-Risk-Management (2).pptx_2024...
Explainable-Artificial-Intelligence-in-Disaster-Risk-Management (2).pptx_2024...Explainable-Artificial-Intelligence-in-Disaster-Risk-Management (2).pptx_2024...
Explainable-Artificial-Intelligence-in-Disaster-Risk-Management (2).pptx_2024...
LiyaShaji4
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
Unit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatioUnit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatio
lakshitakumar291
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
"Heaters in Power Plants: Types, Functions, and Performance Analysis"
"Heaters in Power Plants: Types, Functions, and Performance Analysis""Heaters in Power Plants: Types, Functions, and Performance Analysis"
"Heaters in Power Plants: Types, Functions, and Performance Analysis"
Infopitaara
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
Engineering Chemistry First Year Fullerenes
Engineering Chemistry First Year FullerenesEngineering Chemistry First Year Fullerenes
Engineering Chemistry First Year Fullerenes
5g2jpd9sp4
 
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.
Kamal Acharya
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
How to Make Material Space Qu___ (1).pptx
How to Make Material Space Qu___ (1).pptxHow to Make Material Space Qu___ (1).pptx
How to Make Material Space Qu___ (1).pptx
engaash9
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
comparison of motors.pptx 1. Motor Terminology.ppt
comparison of motors.pptx 1. Motor Terminology.pptcomparison of motors.pptx 1. Motor Terminology.ppt
comparison of motors.pptx 1. Motor Terminology.ppt
yadavmrr7
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 

A Tutorial for GitHub.pdf

  • 1. A Tutorial for Git and GitHub Xiao Li Department of Informatics University of Zurich
  • 2. Agenda  Why use Version (Source) Control Systems  What are Git and GitHub  Basic Git Commands  Fundamentals of GitHub  Using GitHub in Project Implementation
  • 3. 3 Why version control?  Scenario 1: Your program is working You change “just one thing” Your program breaks You change it back Your program is still broken--why?  Has this ever happened to you?
  • 4. 4 Why version control? (part 2)  Your program worked well enough yesterday  You made a lot of improvements last night... ...but you haven't gotten them to work yet  You need to turn in your program now  Has this ever happened to you?
  • 5. 5 Version control for teams  Scenario: You change one part of a program--it works Your co-worker changes another part--it works You put them together--it doesn’t work Some change in one part must have broken something in the other part What were all the changes?
  • 6. 6 Teams (part 2)  Scenario: You make a number of improvements to a class Your co-worker makes a number of different improvements to the same class  How can you merge these changes?
  • 7. 7 Version control systems  A version control system (often called a source code control system) does these things: Keeps multiple (older and newer) versions of everything (not just source code) Requests comments regarding every change Allows “check in” and “check out” of files so you know which files someone else is working on Displays differences between versions
  • 8. Benefits of version control  For working by yourself: Gives you a “time machine” for going back to earlier versions Gives you great support for different versions (standalone, web app, etc.) of the same basic project  For working with others: Greatly simplifies concurrent work, merging changes 8
  • 9. What are Git and GitHub  Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency  GitHub is a web-based Git repository hosting service, which offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features.
  • 10. How to setup Git and GitHub  Download and install the latest version of GitHub Desktop. This will automatically install Git and keep it up- to-date for you.  https://help.github.com/articles/set-up-git/
  • 12. Introduce yourself to Git  On your computer, open the Git Shell application.  Enter these lines (with appropriate changes):  git config --global user.name "John Smith"  git config --global user.email [email protected]  You only need to do this once  If you want to use a different name/email address for a particular project, you can change it for just that project cd to the project directory Use the above commands, but leave out the --global 12
  • 13. The repository  Your top-level working directory contains everything about your project  The working directory probably contains many subdirectories—source code, binaries, documentation, data files, etc.  One of these subdirectories, named .git, is your repository  At any time, you can take a “snapshot” of everything (or selected things) in your project directory, and put it in your repository  This “snapshot” is called a commit object  The commit object contains (1) a set of files, (2) references to the “parents” of the commit object, and (3) a unique “SHA1” name  Commit objects do not require huge amounts of memory  You can work as much as you like in your working directory, but the repository isn’t updated until you commit something 13
  • 14. init and the .git repository  When you said git init in your project directory, or when you cloned an existing project, you created a repository The repository is a subdirectory named .git containing various files The dot indicates a “hidden” directory You do not work directly with the contents of that directory; various git commands do that for you 14
  • 15. Making commits  You do your work in your project directory, as usual  If you create new files and/or folders, they are not tracked by Git unless you ask it to do so  git add newFile1 newFolder1 newFolder2 newFile2  Committing makes a “snapshot” of everything being tracked into your repository  A message telling what you have done is required  git commit –m “Uncrevulated the conundrum bar”  git commit  This version opens an editor for you the enter the message  To finish, save and quit the editor  Format of the commit message  One line containing the complete summary  If more than one line, the second line must be blank 15
  • 16. Commits and graphs  A commit is when you tell git that a change (or addition) you have made is ready to be included in the project  When you commit your change to git, it creates a commit object  A commit object represents the complete state of the project, including all the files in the project  The very first commit object has no “parents”  Usually, you take some commit object, make some changes, and create a new commit object; the original commit object is the parent of the new commit object  Hence, most commit objects have a single parent  You can also merge two commit objects to form a new one  The new commit object has two parents  Hence, commit objects forms a directed graph  Git is all about using and manipulating this graph 16
  • 17. Commit messages  In git, “Commits are cheap.” Do them often.  When you commit, you must provide a one-line message stating what you have done Terrible message: “Fixed a bunch of things” Better message: “Corrected the calculation of median scores”  Commit messages can be very helpful, to yourself as well as to your team members  You can’t say much in one line, so commit often 17
  • 18. Typical workflow  git status See what Git thinks is going on Use this frequently!  Work on your files  git add your editfiles  git commit –m “What I did” 18
  • 19. Keeping it simple  If you:  Make sure you are current with the central repository  Make some improvements to your code  Update the central repository before anyone else does  Then you don’t have to worry about resolving conflicts or working with multiple branches  All the complexity in git comes from dealing with these  Therefore:  Make sure you are up-to-date before starting to work  Commit and update the central repository frequently  If you need help: https://help.github.com/ 19
  • 20. More Commands: Don’t Get Scared. GitHub Desktop can Help You
  • 22. Introduce yourself to GitHub  Register on GitHub https://github.com/  Authenticating to GitHub Desktop https://help.github.com/desktop/guides/getting- started/authenticating-to-github/  Configuring Git for GitHub Desktop https://help.github.com/desktop/guides/getting- started/configuring-git-for-github-desktop/
  • 23. Create or add a repository to GitHub  Create a new repository on GitHub https://help.github.com/articles/create-a-repo/  From GitHub Desktop, then Publish to GitHub https://help.github.com/desktop/guides/contributing/adding-a- repository-from-your-local-computer-to-github-desktop/ Remember to Publish, otherwise your repository would not appear on the GitHub website.
  • 24. Commit your changes on GitHub  From GitHub Website https://help.github.com/articles/create-a-repo/  From GitHub Desktop https://help.github.com/desktop/guides/contributing/committing- and-reviewing-changes-to-your-project/
  • 25. Creating a branch for your work  A branch is a parallel version of the main line of development in the repository, or the default branch (usually master). Use branches to  Develop features  Fix bugs  Safely experiment with new ideas  From the GitHub Website  https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/  From the GitHub Desktop  https://help.github.com/desktop/guides/contributing/creating-a-branch-for-your-work/
  • 26. Synchronizing your branch  As commits are pushed to your project on GitHub, you can keep your local copy of the project in sync with the remote repository. https://help.github.com/desktop/guides/contributing/syncing- your-branch/
  • 27. Viewing the history of your commits  When you click a commit on the commit timeline, you can see more details about the commit, including a diff of the changes the commit introduced.  Each commit shows: The commit message The time the commit was created The committer's username and profile photo (if available) The commit's SHA-1 hash (the unique ID)
  • 28. Revert your commit  If you change your mind about a commit after you create it, you can revert the commit.  When you revert to a previous commit, the revert is also a commit. In addition, the original commit remains in the repository's history.  https://help.github.com/desktop/guides/contributing/reverti ng-a-commit/
  • 29. Fork & Pull: A Collaborative model  A fork is a copy of a repository that you manage. Forks let you make changes to a project without affecting the original repository. You can fetch updates from or submit changes to the original repository with pull requests.  A great example of using forks to propose changes is for bug fixes. Rather than logging an issue for a bug you've found, you can: Fork the repository. Make the fix. Submit a pull request to the project owner.
  • 30. Using GitHub in Project Implementation In the section of project implementation in your project report, you may describe:  How you use GitHub in your project  How version control helps your quality management  How you collaborate with your teammate in GitHub
  • 31. References Some content of the slides are adapted from:  https://help.github.com/desktop/guides/getting-started/  https://help.github.com/desktop/guides/contributing/  https://help.github.com/categories/collaborating/  http://www.cis.upenn.edu/~matuszek/cit591- 2012/Lectures/git.ppt