SlideShare a Scribd company logo
Git : Awesome Distributed Version Control SystemGit : Awesome Distributed Version Control System
Presenter : Raza.Z.Sayed
2
History
● Linux kernel project
● Patch emailing system
● Bitkeeper from 2002 to 2005.
● Why the name Git ?
- “I’m an egotistical bastard, and I name all my
projects after myself.First Linux, now git.” – Linus
Torvalds
● First commit message : 'initial version of “git”,the
information manager from hell'-Linus 4/7/05
3
Basic Concepts
●
Git is not like SVN (Subversion) and is fundamentally different . Git tracks
content not changes or deltas
●
Its like a filesystem. Its a collection of tools that implement tree history storage
and directory content management system.
● Non linear development, distributed development and efficient
- Ruby on Rails Git repository is around 13 Mb and Subversion repository of
the same is around 115 Mb !
● Not a binary but a toolkit design in spirit of unix philosophy (Write programs
that do one thing and do it well)
4
Basic Concepts
●
Git Object Database → .git directory
●
Git Object Types → stored in .git/objects
1. Blob
2. Tree
3. Commit
4. Tag
●
Git Data Model
1. Git Object Types
2. References (Branches and Remotes) → stored in .git/refs
5
Basic Git Workflow
● mkdir my_awesome_project
● cd my_awesome_project
● git init
● Create a file e.g. README.txt
● git status (Optional)
● git add README.txt (Add to staging)
● git commit -m “first commit”
6
Basic Git Workflow
● Make some changes to README.txt
● Create a new file e.g. hello.rb
● git status
● git add hello.rb README.txt or git add . or git add --all
● git commit -m “another commit”
● Make changes to hello.rb
● git commit -a -m “added foo method” (Wont add
untracked files to staging. git add them separately)
7
Different ways to add
● git add <list of files> (Add the list of files)
● git add --all (Add all files from the project.)
● git add . (Add all files from the project)
● git add *.txt (Add all txt files in current dir)
● git add “*.txt” (Add all txt files from the project)
● git add docs/*.txt (Add all txt files from docs dir)
● git add docs/ (Add all files from docs dir)
8
Viewing changes
● git diff (Show unstaged changes since last
commit)
● git diff --staged (show staged changes since
last commit)
● git log (show project history)
9
Undo unstaged changes
● git checkout . (Blow away all changes since
last commit)
● git checkout <list of files> (Blow away changes
to specified files since last commit)
10
Unstage changes
● git reset HEAD (Unstage all staged files)
● git reset HEAD <list of files> (Unstage
particular files) e.g. git reset HEAD
README.txt or git reset HEAD README.txt
hello.rb
11
Undo commits
● git reset soft HEAD^ (Undo last commit and move changes
back to staging) or git reset soft HEAD~1
● git reset soft HEAD^^ (Undo last two commits and move
changes back to staging) or git reset soft HEAD~2
● git reset hard HEAD^ (Undo last commit and blow away all
changes) or git reset hard HEAD~1
● git reset hard HEAD^^^ (Undo last three commits and blow
away all changes) or git reset hard HEAD~3
● git commit --amend -m “New commit message” (Change
the last commit message)
12
Sharing and Collaborating
● Lots of different code hosting services to
choose from e.g. Unfuddle, Github, Bitbucket
etc. or setup your own server.
● Create a git repo on the server. This is called a
remote repository.
● Inside your project dir on your local machine :
git remote add <some arbit name for the
remote repo> <path of remote repo>
13
Sharing and Collaborating
● git remote -v (show remote repositories
associated with the project)
● git push -u <remote repo name> <branch
name> e.g. git push -u origin master
● git pull (Pull changes from the remote repo)
● git remote rm <remote repo name> (Delete a
remote repo from the project)
14
Sharing and Collaborating
● Types of git repo urls : https://.. (Read only or read
write depending upon permissions) , git://.. (Git read
only), git@.. (SSH read write)
● git clone <remote repo url> or git clone <remote repo
url> [local name]
● git clone does the following three things. 1) Downloads
the entire repo into a new directory 2) Adds origin
remote pointing it to clone url 3) checks out the master
branch i.e. sets local repo HEAD to point to the master
branch
15
Branching
● Need to work on a new feature or fix a bug that
will take time ?. Create a new branch to work on
it.
● git branch <branch name> (Creates the branch)
● git checkout <branch name> (Switch to the
branch)
● git checkout -b <branch name> (Shortcut to
create and switch to a branch in one step)
16
Basic Branching Workflow
● git checkout -b cool_feature
● echo “This is readme for the cool feature” >
README.txt
● git add README.txt
● git commit -m “first commit in cool_feature branch”
● git checkout master
● git merge cool_feature
● git branch -d cool_feature (Delete the branch as were
done with it)
17
Types of Branch Merge
● Fast Forward Merge
● Non Fast Forward Merge (Recursive Merge)
● Recursive Merge creates an extra commit
automatically called a “Merge commit”
18
Conflicts
● Can either arise during git push or while doing a
merge (merge conflict)
● git push conflict scenario. Do a git pull first to fix
● Two cases in which merge conflicts can arise. 1)
During merging a local branch 2) Doing a git pull
● git pull = git fetch+git merge. What is origin/master ?
● Resolving merge conflicts
19
Sharing local branches
●
A wants to create a new branch and share it.
git checkout -b awesome_new_feature
git push origin awesome_new_feature
●
B wants to collaborate on the new branch.
git pull
git checkout awesome_new_feature
●
Listing remote branches : git branch -r
●
Getting detailed information about remote branches : git remote show origin
●
Deleting remote branches.
git push origin :awesome_new_feature
git branch -d awesome_new_feature. If this does not work then,
git branch -D awesome_new_feature
●
Cleaning up local references to deleted remote branches : git remote prune origin
20
Tagging
● What are tags ?
● Listing all tags : git tag
● Creating a new tag : git tag -a v1.0 -m “version
1.0”
● Checkout code at a particular commit : git
checkout v1.0
● Sharing tags : git push --tags
21
Rebase
● What is a rebase and why its better than a merge ?
● Dont do git pull ! . Instead do a fetch + rebase.
● Remote branch rebase workflow
git fetch
git rebase
● Local branch rebase workflow. e.g. To rebase branch new_feature into master
git checkout new_feature
git rebase master
git checkout master
git merge new_feature
22
Ignoring Files
● Only for yourself
Put exclude patterns in .git/info/exclude file
● For everyone
Put exclude patterns in .gitignore file in the
project root directory
● Untracking files
git rm --cached <file name>
23
References
● Git Community Book - http://git-scm.com/book
● Git Branching -
http://pcottle.github.com/learnGitBranching/
● Git for computer scientists -
http://eagain.net/articles/git-for-computer-scientists/
● Visual Git Reference -
http://marklodato.github.com/visual-git-guide/index-
24
Thank You
Ad

More Related Content

What's hot (20)

Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Colin Su
 
Git commands
Git commandsGit commands
Git commands
Javed Hussain
 
Formation git
Formation gitFormation git
Formation git
Ghariani Tewfik
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
DivineOmega
 
Git Basics
Git BasicsGit Basics
Git Basics
Ryan Condron
 
Git Tricks
Git TricksGit Tricks
Git Tricks
Ivelina Dimova
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
rschwietzke
 
Getting Started on distributed version control with git
Getting Started on distributed version control with gitGetting Started on distributed version control with git
Getting Started on distributed version control with git
Anoop Thomas Mathew
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Shilu Shrestha
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
Yodalee
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
 
Git presentation
Git presentationGit presentation
Git presentation
Vikas Yaligar
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
Gareth Hall
 
Git 101
Git 101Git 101
Git 101
jayrparro
 
Open source
Open sourceOpen source
Open source
onaelmangabo
 
Contributing to open source using Git
Contributing to open source using GitContributing to open source using Git
Contributing to open source using Git
Yan Vugenfirer
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentals
RajKharvar
 
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, TrivandrumIntroduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
AbhijitNarayan2
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
Luigi De Russis
 
Git commands
Git commandsGit commands
Git commands
Viyaan Jhiingade
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Colin Su
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
DivineOmega
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
rschwietzke
 
Getting Started on distributed version control with git
Getting Started on distributed version control with gitGetting Started on distributed version control with git
Getting Started on distributed version control with git
Anoop Thomas Mathew
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
Yodalee
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
Gareth Hall
 
Contributing to open source using Git
Contributing to open source using GitContributing to open source using Git
Contributing to open source using Git
Yan Vugenfirer
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentals
RajKharvar
 
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, TrivandrumIntroduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
AbhijitNarayan2
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
Luigi De Russis
 

Viewers also liked (20)

Capitulo 1 1expresate
Capitulo 1 1expresateCapitulo 1 1expresate
Capitulo 1 1expresate
Sherray Hurlbert
 
Open educational resources
Open educational resourcesOpen educational resources
Open educational resources
Sherray Hurlbert
 
Introduction into Social Media
Introduction into Social MediaIntroduction into Social Media
Introduction into Social Media
studente1000
 
REQUISITOS PARA INSTALAR WINDOWS XP Y WINDOWS 7
REQUISITOS PARA INSTALAR WINDOWS XP Y WINDOWS 7REQUISITOS PARA INSTALAR WINDOWS XP Y WINDOWS 7
REQUISITOS PARA INSTALAR WINDOWS XP Y WINDOWS 7
no trabajo mis padress me mantienenn <3 . (:
 
Painter sung sam_park
Painter sung sam_parkPainter sung sam_park
Painter sung sam_park
Michael Strong
 
Eclampsia 4-real-presentation
Eclampsia 4-real-presentationEclampsia 4-real-presentation
Eclampsia 4-real-presentation
Adventist Medical Center-Iligan
 
World cup fanatics
World cup fanaticsWorld cup fanatics
World cup fanatics
Michael Strong
 
Nota sej (bab 1) f.4
Nota sej (bab 1) f.4Nota sej (bab 1) f.4
Nota sej (bab 1) f.4
hanazhar
 
Red
RedRed
Red
Michael Strong
 
Best Denver post 2009
Best Denver post 2009Best Denver post 2009
Best Denver post 2009
Michael Strong
 
Susan alex july
Susan alex julySusan alex july
Susan alex july
MaherBirdAssociates
 
Company meeting v_rebecca_emma
Company meeting v_rebecca_emmaCompany meeting v_rebecca_emma
Company meeting v_rebecca_emma
MaherBirdAssociates
 
Zoe vs Gravesend Developers
Zoe vs Gravesend DevelopersZoe vs Gravesend Developers
Zoe vs Gravesend Developers
MaherBirdAssociates
 
Laura Heather Glenn Chris - Sept 2011
Laura Heather Glenn Chris - Sept 2011Laura Heather Glenn Chris - Sept 2011
Laura Heather Glenn Chris - Sept 2011
MaherBirdAssociates
 
Ad

Similar to Git tech talk (20)

Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
seungzzang Kim
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
Majid Hosseini
 
Gn unify git
Gn unify gitGn unify git
Gn unify git
Priyanka Nag
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
Arulmurugan Rajaraman
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
Tahsin Abrar
 
Intro to Git
Intro to GitIntro to Git
Intro to Git
Shadab Khan
 
Git github
Git githubGit github
Git github
Anurag Deb
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
GDSC UofT Mississauga
 
Introduction of Git
Introduction of GitIntroduction of Git
Introduction of Git
Wayne Chen
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
Sebin Benjamin
 
Git training
Git trainingGit training
Git training
eric7master
 
Introduction to git, a version control system
Introduction to git, a version control systemIntroduction to git, a version control system
Introduction to git, a version control system
Kumaresh Chandra Baruri
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
Piotr Benetkiewicz
 
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a gitVincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
VincitOy
 
Git essentials
Git essentialsGit essentials
Git essentials
Otto Kekäläinen
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
9 series
 
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
BADR
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
seungzzang Kim
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
Majid Hosseini
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
Tahsin Abrar
 
Introduction of Git
Introduction of GitIntroduction of Git
Introduction of Git
Wayne Chen
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
Sebin Benjamin
 
Introduction to git, a version control system
Introduction to git, a version control systemIntroduction to git, a version control system
Introduction to git, a version control system
Kumaresh Chandra Baruri
 
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a gitVincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
VincitOy
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
9 series
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
BADR
 
Ad

Recently uploaded (20)

HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 

Git tech talk

  • 1. Git : Awesome Distributed Version Control SystemGit : Awesome Distributed Version Control System Presenter : Raza.Z.Sayed
  • 2. 2 History ● Linux kernel project ● Patch emailing system ● Bitkeeper from 2002 to 2005. ● Why the name Git ? - “I’m an egotistical bastard, and I name all my projects after myself.First Linux, now git.” – Linus Torvalds ● First commit message : 'initial version of “git”,the information manager from hell'-Linus 4/7/05
  • 3. 3 Basic Concepts ● Git is not like SVN (Subversion) and is fundamentally different . Git tracks content not changes or deltas ● Its like a filesystem. Its a collection of tools that implement tree history storage and directory content management system. ● Non linear development, distributed development and efficient - Ruby on Rails Git repository is around 13 Mb and Subversion repository of the same is around 115 Mb ! ● Not a binary but a toolkit design in spirit of unix philosophy (Write programs that do one thing and do it well)
  • 4. 4 Basic Concepts ● Git Object Database → .git directory ● Git Object Types → stored in .git/objects 1. Blob 2. Tree 3. Commit 4. Tag ● Git Data Model 1. Git Object Types 2. References (Branches and Remotes) → stored in .git/refs
  • 5. 5 Basic Git Workflow ● mkdir my_awesome_project ● cd my_awesome_project ● git init ● Create a file e.g. README.txt ● git status (Optional) ● git add README.txt (Add to staging) ● git commit -m “first commit”
  • 6. 6 Basic Git Workflow ● Make some changes to README.txt ● Create a new file e.g. hello.rb ● git status ● git add hello.rb README.txt or git add . or git add --all ● git commit -m “another commit” ● Make changes to hello.rb ● git commit -a -m “added foo method” (Wont add untracked files to staging. git add them separately)
  • 7. 7 Different ways to add ● git add <list of files> (Add the list of files) ● git add --all (Add all files from the project.) ● git add . (Add all files from the project) ● git add *.txt (Add all txt files in current dir) ● git add “*.txt” (Add all txt files from the project) ● git add docs/*.txt (Add all txt files from docs dir) ● git add docs/ (Add all files from docs dir)
  • 8. 8 Viewing changes ● git diff (Show unstaged changes since last commit) ● git diff --staged (show staged changes since last commit) ● git log (show project history)
  • 9. 9 Undo unstaged changes ● git checkout . (Blow away all changes since last commit) ● git checkout <list of files> (Blow away changes to specified files since last commit)
  • 10. 10 Unstage changes ● git reset HEAD (Unstage all staged files) ● git reset HEAD <list of files> (Unstage particular files) e.g. git reset HEAD README.txt or git reset HEAD README.txt hello.rb
  • 11. 11 Undo commits ● git reset soft HEAD^ (Undo last commit and move changes back to staging) or git reset soft HEAD~1 ● git reset soft HEAD^^ (Undo last two commits and move changes back to staging) or git reset soft HEAD~2 ● git reset hard HEAD^ (Undo last commit and blow away all changes) or git reset hard HEAD~1 ● git reset hard HEAD^^^ (Undo last three commits and blow away all changes) or git reset hard HEAD~3 ● git commit --amend -m “New commit message” (Change the last commit message)
  • 12. 12 Sharing and Collaborating ● Lots of different code hosting services to choose from e.g. Unfuddle, Github, Bitbucket etc. or setup your own server. ● Create a git repo on the server. This is called a remote repository. ● Inside your project dir on your local machine : git remote add <some arbit name for the remote repo> <path of remote repo>
  • 13. 13 Sharing and Collaborating ● git remote -v (show remote repositories associated with the project) ● git push -u <remote repo name> <branch name> e.g. git push -u origin master ● git pull (Pull changes from the remote repo) ● git remote rm <remote repo name> (Delete a remote repo from the project)
  • 14. 14 Sharing and Collaborating ● Types of git repo urls : https://.. (Read only or read write depending upon permissions) , git://.. (Git read only), git@.. (SSH read write) ● git clone <remote repo url> or git clone <remote repo url> [local name] ● git clone does the following three things. 1) Downloads the entire repo into a new directory 2) Adds origin remote pointing it to clone url 3) checks out the master branch i.e. sets local repo HEAD to point to the master branch
  • 15. 15 Branching ● Need to work on a new feature or fix a bug that will take time ?. Create a new branch to work on it. ● git branch <branch name> (Creates the branch) ● git checkout <branch name> (Switch to the branch) ● git checkout -b <branch name> (Shortcut to create and switch to a branch in one step)
  • 16. 16 Basic Branching Workflow ● git checkout -b cool_feature ● echo “This is readme for the cool feature” > README.txt ● git add README.txt ● git commit -m “first commit in cool_feature branch” ● git checkout master ● git merge cool_feature ● git branch -d cool_feature (Delete the branch as were done with it)
  • 17. 17 Types of Branch Merge ● Fast Forward Merge ● Non Fast Forward Merge (Recursive Merge) ● Recursive Merge creates an extra commit automatically called a “Merge commit”
  • 18. 18 Conflicts ● Can either arise during git push or while doing a merge (merge conflict) ● git push conflict scenario. Do a git pull first to fix ● Two cases in which merge conflicts can arise. 1) During merging a local branch 2) Doing a git pull ● git pull = git fetch+git merge. What is origin/master ? ● Resolving merge conflicts
  • 19. 19 Sharing local branches ● A wants to create a new branch and share it. git checkout -b awesome_new_feature git push origin awesome_new_feature ● B wants to collaborate on the new branch. git pull git checkout awesome_new_feature ● Listing remote branches : git branch -r ● Getting detailed information about remote branches : git remote show origin ● Deleting remote branches. git push origin :awesome_new_feature git branch -d awesome_new_feature. If this does not work then, git branch -D awesome_new_feature ● Cleaning up local references to deleted remote branches : git remote prune origin
  • 20. 20 Tagging ● What are tags ? ● Listing all tags : git tag ● Creating a new tag : git tag -a v1.0 -m “version 1.0” ● Checkout code at a particular commit : git checkout v1.0 ● Sharing tags : git push --tags
  • 21. 21 Rebase ● What is a rebase and why its better than a merge ? ● Dont do git pull ! . Instead do a fetch + rebase. ● Remote branch rebase workflow git fetch git rebase ● Local branch rebase workflow. e.g. To rebase branch new_feature into master git checkout new_feature git rebase master git checkout master git merge new_feature
  • 22. 22 Ignoring Files ● Only for yourself Put exclude patterns in .git/info/exclude file ● For everyone Put exclude patterns in .gitignore file in the project root directory ● Untracking files git rm --cached <file name>
  • 23. 23 References ● Git Community Book - http://git-scm.com/book ● Git Branching - http://pcottle.github.com/learnGitBranching/ ● Git for computer scientists - http://eagain.net/articles/git-for-computer-scientists/ ● Visual Git Reference - http://marklodato.github.com/visual-git-guide/index-