SlideShare a Scribd company logo
1 of 37
Download to read offline
Intro to
Git & GitHub
Hands-on workshop
@angeloseby | #gdscbmc
Whoa!
Hi, I am Angelo Seby
GDSC BMC Lead🤩 - Flutter Developer💙 - ML Enthusiast🤖
@angeloseby | #gdscbmc
Heyy!
Hi, I am Vijay
GDSC BMC Outreach Lead💌 - Python Developer💛 - ML Enthusiast🤖
@angeloseby | #gdscbmc
Setup Check
@angeloseby | #gdscbmc
just type ‘git’ in your terminal
(GDSC BMC)
I am not a git expert….
@angeloseby | #gdscbmc
(GDSC BMC)
Agenda
Git History
Git Concepts
Basic Git Workflow
Branching
Resources
@angeloseby | #gdscbmc
(GDSC BMC)
Git History
@angeloseby | #gdscbmc
A ‘git’ is a cranky old man
(GDSC BMC)
@angeloseby | #gdscbmc
● Git is a free and open source distributed Version
Control System
● Can handle small to very large projects with speed
and efficiency
● Created by Linus Torvalds, launched April 7 2005
● Every Git working directory contains a repository
with complete history and full revision capabilities
● Git is local , not dependant of a network or a
central server
(GDSC BMC)
@angeloseby | #gdscbmc
Goals of Git
● Speed
● Non - linear development / Parallel branches
● Fully distributed
● Able to handle large projects efficiently
(GDSC BMC)
Git Concepts
@angeloseby | #gdscbmc
(GDSC BMC)
@angeloseby | #gdscbmc
VERSION CONTROL
A system that
records change
over time.
@angeloseby | #gdscbmc
(GDSC BMC)
@angeloseby | #gdscbmc
GIT REPOSITORY (REPO)
A container for
project files
@angeloseby | #gdscbmc
(GDSC BMC)
@angeloseby | #gdscbmc
SNAPSHOTS
Information about
the state of the
project
@angeloseby | #gdscbmc
(GDSC BMC)
Basic Git Workflow
@angeloseby | #gdscbmc
Let’s ‘git’ with it…
(GDSC BMC)
@angeloseby | #gdscbmc
git --help
@angeloseby | #gdscbmc
Git’s
documentation
is built in - try it
for yourself
(GDSC BMC)
@angeloseby | #gdscbmc
Setup the
workspace
@angeloseby | #gdscbmc
Make a folder
named ‘project’
in desktop of
your system
$ mkdir project // Make new folder
$ cd project // Change directory
c:/desktop/project> $
Goto Desktop -> Right Click -> Open Terminal Here
(GDSC BMC)
@angeloseby | #gdscbmc
Config git
@angeloseby | #gdscbmc
Set the email
and name for Git
to use when you
commit
/project> $ git config --global user.name "John Doe"
/project> $ git config --global user.email bugs@gmail.com
(GDSC BMC)
@angeloseby | #gdscbmc
Creating git repo
@angeloseby | #gdscbmc
Set the email
and name for Git
to use when you
commit
/project> $ git init
To create a new local git repo in your cd
This will create a .git directory in your cd
Then you can commit files in that directory into the repo.
/project> $ git clone url
To clone a remote repo into to your cd
This will create the given local directory, containing a working
copy of the files from the repo, and a .git directory
(GDSC BMC)
@angeloseby | #gdscbmc
git status
@angeloseby | #gdscbmc
View the status
of your files in
the working
directory and
staging area
/project> $ git status
To view the git status
It lets you see which changes have been staged, which haven't,
and which files aren't being tracked by Git.
/project> $ git status -s
To view the short version of git status
(GDSC BMC)
@angeloseby | #gdscbmc
Add a file
@angeloseby | #gdscbmc
Create a file in
your cd
Create a new text file in your in cd.
Write something in it 😃
(GDSC BMC)
@angeloseby | #gdscbmc
git add
@angeloseby | #gdscbmc
Add the files that
are created and
modified for
staging commit
/project> $ git add file name
To add a single file for staging commit
Now when check the git status you can see that the added file
is now added to the tracked files list
/project> $ git add .
To add all the files for staging commit
This will add all the new and modified files for staging to commit
(GDSC BMC)
@angeloseby | #gdscbmc
git reset
@angeloseby | #gdscbmc
Remove your file
from staging /project> $ git reset filename
To reset filename
Removes that file from staged files
(GDSC BMC)
@angeloseby | #gdscbmc
git commit
@angeloseby | #gdscbmc
Captures a
snapshot of the
project's
currently staged
changes
/project> $ git commit -m “Initial Commit”
To save a current version of repo we commit
This will commit (make a safe zone) with all the tracked /
staged files
-m stands for commit message , it can be any
meaningful message.
The statement in the quoted enclosed near to it is the
commit msg
(GDSC BMC)
@angeloseby | #gdscbmc
git diff
@angeloseby | #gdscbmc
To view the
difference
between files
/project> $ git diff
To view the difference between staged and unstaged files
To the view the difference between staged and last
committed file
/project> $ git diff --cached
(GDSC BMC)
@angeloseby | #gdscbmc
git log
@angeloseby | #gdscbmc
See the git
commit history
in command line
interface
/project> $ git log
To see the history of all git commits with message & author
To the view the shorter version of git history
/project> $ git log --oneline
(GDSC BMC)
@angeloseby | #gdscbmc
Amend a commit
@angeloseby | #gdscbmc
Edit the last
commit if you
forgot to add
some file
/project> $ git commit -amend
This will take all the files in the staging area and add it to the
last commit
(GDSC BMC)
Branching
@angeloseby | #gdscbmc
‘git’ to the branch of tree
@angeloseby | #gdscbmc
@angeloseby | #gdscbmc
/project> $ git branch
Lists all branches in the repository
@angeloseby | #gdscbmc
@angeloseby | #gdscbmc
/project> $ git branch name
Creates a new branch from current working branch with given name
@angeloseby | #gdscbmc
@angeloseby | #gdscbmc
/project> $ git checkout branch_name
Switch to the local branch with given branch name
If such branch doesn’t exist, creates a new branch with that name from the current
working branch
@angeloseby | #gdscbmc
@angeloseby | #gdscbmc
/project> $ git branch -d branch_name
/project> $ git branch -D branch_name
Both deletes a branch with given name
@angeloseby | #gdscbmc
@angeloseby | #gdscbmc
/project> $ git merge branch_name
Merges the branch with given branch name to the currently working branch
(GDSC BMC)
Resources
@angeloseby | #gdscbmc
Continue learning about ‘git’
@angeloseby | #gdscbmc
@angeloseby | #gdscbmc
Read the manual
https://git-scm.com/doc
@angeloseby | #gdscbmc
@angeloseby | #gdscbmc
@angeloseby | #gdscbmc
Learn git branching like a game
https://learngitbranching.js.org/
@angeloseby | #gdscbmc
@angeloseby | #gdscbmc
@angeloseby | #gdscbmc
Git tutorial - Atlassian
https://www.atlassian.com/git/tutorials
@angeloseby | #gdscbmc
Thank You
@angeloseby | #gdscbmc

More Related Content

Similar to Introduction to Git

Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer Cheatsheet
Abdul Basit
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
Terry Wang
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
Terry Wang
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
King Hom
 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
King Hom
 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
King Hom
 

Similar to Introduction to Git (20)

Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer Cheatsheet
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git
GitGit
Git
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Hello git
Hello git Hello git
Hello git
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Git
GitGit
Git
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
 
Git github
Git githubGit github
Git github
 
Git basics : a beginner's guide
Git basics : a beginner's guideGit basics : a beginner's guide
Git basics : a beginner's guide
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010
 
Git cheat-sheet 2021
Git cheat-sheet 2021Git cheat-sheet 2021
Git cheat-sheet 2021
 

Recently uploaded

Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
Elizabeth Walsh
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 

Recently uploaded (20)

REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
Pharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdfPharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdf
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
 
PUBLIC FINANCE AND TAXATION COURSE-1-4.pdf
PUBLIC FINANCE AND TAXATION COURSE-1-4.pdfPUBLIC FINANCE AND TAXATION COURSE-1-4.pdf
PUBLIC FINANCE AND TAXATION COURSE-1-4.pdf
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 

Introduction to Git

  • 1. Intro to Git & GitHub Hands-on workshop @angeloseby | #gdscbmc
  • 2. Whoa! Hi, I am Angelo Seby GDSC BMC Lead🤩 - Flutter Developer💙 - ML Enthusiast🤖 @angeloseby | #gdscbmc
  • 3. Heyy! Hi, I am Vijay GDSC BMC Outreach Lead💌 - Python Developer💛 - ML Enthusiast🤖 @angeloseby | #gdscbmc
  • 4. Setup Check @angeloseby | #gdscbmc just type ‘git’ in your terminal
  • 5. (GDSC BMC) I am not a git expert…. @angeloseby | #gdscbmc
  • 6. (GDSC BMC) Agenda Git History Git Concepts Basic Git Workflow Branching Resources @angeloseby | #gdscbmc
  • 7. (GDSC BMC) Git History @angeloseby | #gdscbmc A ‘git’ is a cranky old man
  • 8. (GDSC BMC) @angeloseby | #gdscbmc ● Git is a free and open source distributed Version Control System ● Can handle small to very large projects with speed and efficiency ● Created by Linus Torvalds, launched April 7 2005 ● Every Git working directory contains a repository with complete history and full revision capabilities ● Git is local , not dependant of a network or a central server
  • 9. (GDSC BMC) @angeloseby | #gdscbmc Goals of Git ● Speed ● Non - linear development / Parallel branches ● Fully distributed ● Able to handle large projects efficiently
  • 11. (GDSC BMC) @angeloseby | #gdscbmc VERSION CONTROL A system that records change over time. @angeloseby | #gdscbmc
  • 12. (GDSC BMC) @angeloseby | #gdscbmc GIT REPOSITORY (REPO) A container for project files @angeloseby | #gdscbmc
  • 13. (GDSC BMC) @angeloseby | #gdscbmc SNAPSHOTS Information about the state of the project @angeloseby | #gdscbmc
  • 14. (GDSC BMC) Basic Git Workflow @angeloseby | #gdscbmc Let’s ‘git’ with it…
  • 15. (GDSC BMC) @angeloseby | #gdscbmc git --help @angeloseby | #gdscbmc Git’s documentation is built in - try it for yourself
  • 16. (GDSC BMC) @angeloseby | #gdscbmc Setup the workspace @angeloseby | #gdscbmc Make a folder named ‘project’ in desktop of your system $ mkdir project // Make new folder $ cd project // Change directory c:/desktop/project> $ Goto Desktop -> Right Click -> Open Terminal Here
  • 17. (GDSC BMC) @angeloseby | #gdscbmc Config git @angeloseby | #gdscbmc Set the email and name for Git to use when you commit /project> $ git config --global user.name "John Doe" /project> $ git config --global user.email bugs@gmail.com
  • 18. (GDSC BMC) @angeloseby | #gdscbmc Creating git repo @angeloseby | #gdscbmc Set the email and name for Git to use when you commit /project> $ git init To create a new local git repo in your cd This will create a .git directory in your cd Then you can commit files in that directory into the repo. /project> $ git clone url To clone a remote repo into to your cd This will create the given local directory, containing a working copy of the files from the repo, and a .git directory
  • 19. (GDSC BMC) @angeloseby | #gdscbmc git status @angeloseby | #gdscbmc View the status of your files in the working directory and staging area /project> $ git status To view the git status It lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git. /project> $ git status -s To view the short version of git status
  • 20. (GDSC BMC) @angeloseby | #gdscbmc Add a file @angeloseby | #gdscbmc Create a file in your cd Create a new text file in your in cd. Write something in it 😃
  • 21. (GDSC BMC) @angeloseby | #gdscbmc git add @angeloseby | #gdscbmc Add the files that are created and modified for staging commit /project> $ git add file name To add a single file for staging commit Now when check the git status you can see that the added file is now added to the tracked files list /project> $ git add . To add all the files for staging commit This will add all the new and modified files for staging to commit
  • 22. (GDSC BMC) @angeloseby | #gdscbmc git reset @angeloseby | #gdscbmc Remove your file from staging /project> $ git reset filename To reset filename Removes that file from staged files
  • 23. (GDSC BMC) @angeloseby | #gdscbmc git commit @angeloseby | #gdscbmc Captures a snapshot of the project's currently staged changes /project> $ git commit -m “Initial Commit” To save a current version of repo we commit This will commit (make a safe zone) with all the tracked / staged files -m stands for commit message , it can be any meaningful message. The statement in the quoted enclosed near to it is the commit msg
  • 24. (GDSC BMC) @angeloseby | #gdscbmc git diff @angeloseby | #gdscbmc To view the difference between files /project> $ git diff To view the difference between staged and unstaged files To the view the difference between staged and last committed file /project> $ git diff --cached
  • 25. (GDSC BMC) @angeloseby | #gdscbmc git log @angeloseby | #gdscbmc See the git commit history in command line interface /project> $ git log To see the history of all git commits with message & author To the view the shorter version of git history /project> $ git log --oneline
  • 26. (GDSC BMC) @angeloseby | #gdscbmc Amend a commit @angeloseby | #gdscbmc Edit the last commit if you forgot to add some file /project> $ git commit -amend This will take all the files in the staging area and add it to the last commit
  • 27. (GDSC BMC) Branching @angeloseby | #gdscbmc ‘git’ to the branch of tree
  • 28. @angeloseby | #gdscbmc @angeloseby | #gdscbmc /project> $ git branch Lists all branches in the repository
  • 29. @angeloseby | #gdscbmc @angeloseby | #gdscbmc /project> $ git branch name Creates a new branch from current working branch with given name
  • 30. @angeloseby | #gdscbmc @angeloseby | #gdscbmc /project> $ git checkout branch_name Switch to the local branch with given branch name If such branch doesn’t exist, creates a new branch with that name from the current working branch
  • 31. @angeloseby | #gdscbmc @angeloseby | #gdscbmc /project> $ git branch -d branch_name /project> $ git branch -D branch_name Both deletes a branch with given name
  • 32. @angeloseby | #gdscbmc @angeloseby | #gdscbmc /project> $ git merge branch_name Merges the branch with given branch name to the currently working branch
  • 33. (GDSC BMC) Resources @angeloseby | #gdscbmc Continue learning about ‘git’
  • 34. @angeloseby | #gdscbmc @angeloseby | #gdscbmc Read the manual https://git-scm.com/doc @angeloseby | #gdscbmc
  • 35. @angeloseby | #gdscbmc @angeloseby | #gdscbmc Learn git branching like a game https://learngitbranching.js.org/ @angeloseby | #gdscbmc
  • 36. @angeloseby | #gdscbmc @angeloseby | #gdscbmc Git tutorial - Atlassian https://www.atlassian.com/git/tutorials @angeloseby | #gdscbmc