SlideShare a Scribd company logo
Git
Amit K Mathur
akmathur@gmail.com
Introductions
● Job description & Experience with Git
● Laptop, notebook & pen
● List your topics under “Make sure you cover”
Introductions
● What's your target project? Job description?
● Experience level with any VCS
● Linux or Windows?
● Laptop, notebook & pen
● List your topics under “Make sure you cover”
4
Contents – session 1
● Why version control
● DVCS
● History, characteristics
● Installation and config
● Hands on
5
Contents – session 2
● Important Concepts
● Collaborate with Git
● Rewrite history
● Development help from Git
6
Contents – session 3
● Debug with Git
● Working with remotes
● Advantages of Git – review
● Advanced commands
7
Contents – session 4
● Best practices
● Workflows
● UI
● Migrating from SVN or Clearcase to Git
● Git Internals
8
Session 1
9
Why version control
● History of code changes – your own & by
others
● Collaborate: merge multiple changes in same
file
● Revert
● Blame
10
DVCS
● No central repo
● Ops are fast – no server
● No network required - work offline. Whole copy
of the repo available locally
● Alternatives DVCS – Mercurial, BitKeeper
11
Git's history
● Designed by Linus Torvalds in 2005
● For speedy and distributed dev of Linux
● Git means “stupid person”
● Most widely used VCS currently
● Linux, POSIX, OS X, Windows
12
Characteristics
● Global commit IDs – SHA1 sig, non-sequential
● Tracks patches
● Lightweight branching
● Fast
13
Characteristics
● Good for
– Large projects, large number of devs
– Multiple releases
– Multiple workflows
● Bad interface over an excellent technology
– Non-intuitive command options
– Not very good GUI
14
Install Git
Linux
apt-get install git-core
yum install git
Windows
http://www.siteground.com/tutorials/git/win_installation.htm
http://msysgit.github.io
http://git-scm.org
git help <command>
Generate Public/Private Keys
15
Set up a repo
● New local project
– git init
● On server: git init –bare
– Omits working copy
– .git added to folder by convention
● Get from server
– git clone
● Cloud Hosted (github)
16
Setup
$ git config
$ git config --global user.name "Your
Name"
$ git config --global user.email
you@yourdomain.example.com
Edit ~/.gitconfig to add shortcuts &
colours
17
Hands on
Typical projects start by cloning a public repo or getting zip of source
git clone git://github.com/akmathur/demo_app2
Make a small change
Try common commands:
git status
git diff
git add .
git commit -m “[bugfix] handled zero input”
git log, git log -p, git log --since=2016/01/15
git show HEAD^
git show HEAD~2
18
Session 2
19
Important concepts
Staging area - Build commits incrementally
git add
git diff –-cached
git reset HEAD <file name>
git add
git rm
20
Important concepts
Branching - easy to create, merge, destroy
git branch <name>
git branch
git checkout <name>
git branch -D <name>
git merge <name>
git log HEAD..<name>
21
Collaborate
● Branching
– Work on same branch or share branch names
– git push -u origin <branch-name>
● Share patches
– git diff, git apply
22
Modify history
git rebase -i <base commit>
• Reorder commits, create linear history
git revert
• Undo by reversing a commit
git reset
• Undo by going back in history
git commit –amend
git checkout <filename>
git reset HEAD <filename>
23
Development help
Interactive add
git add -i, git add -p
Tagging
git tag
Ask git to ignore files
.gitignore
Stash
git stash save “bug 2 in progress”
git stash pop
24
Session 3
25
Git basics review
VCS vs DVCS
Install and Setup
Making a commit – staging area
Common commands - log, diff, adding and removing files
Branching, merging
Modifying history – revert, reset, commit --amend,
rebase
Development help – stash, tag, add -p
26
Debug with Git
Narrow down to last working version
git bisect
Who put in this line
git blame
27
Rebase & Cherry-pick
Move commits from a local branch into master
git rebase <branch-name>
Move only selected commits
git cherry-pick <branch-name>
28
Working with remote repo
git remote add origin <url>
git remote, git remote show <name>, git remote
remove <name>
git fetch
git pull origin <branch-name>
git push -u origin <local-branch-name>
● Pull/Push can be done to any repo. Central is by convention only
● Remote branch names are origin/<branch-name>
29
Set up a remote repo
cd /somewhere/on/hard/drive
mkdir my_project.git
cd my_project.git
git init --bare
cd /home/work/my_project
git init
# create some files
# add all files e.g. *.cpp *.h
git add *
git commit -m "initial commit"
git remote add origin /somewhere/on/hard/drive/my_project.git
git push -u origin master
30
Collaboration
● Configure your remotes (default “origin” should
always be there)
● Commit to local repo
● git pull (or git fetch and then merge)
● Resolve merge conflicts if any
● git push
31
Hands-on Exercises
● Someone removed a file. What did
the file have when it was removed?
● Find how a file looked 2 commits
ago?
● Two bug fixes were committed
together in one commit. Separate
them out in two different branches.
32
Hands-on Exercises
● Get a branch from your friend's
repo but push it to the central
repo as your branch
● Someone committed some changes but
deleted some files by mistake in
that commit. How will restore the
deleted files while keeping rest of
the changes?
33
Review
Debug commands – git blame, git bisect
Rebase & Cherry pick
Remote repo – setup, pull, resolve merge
conflicts, push
34
Session 4
35
Advantages of Git
● Lightweight branching
● Modify History
● Collaboration
● Debugging
● Distributed development
36
Advanced commands
● git gc
● git prune
● git fsck
● git archive
● Hooks
37
Best practices
● Commit often, 1 line commit message
● Don't rebase after push
● Use branches liberally
● Don't fear mistakes – anything can be undone
38
Workflows
Use cases: Enterprise, Central managed repo
● Get a bug or a feature
● Start a local branch
● Commit often, test, satisfy yourself
● Rebase and arrange commits
● Merge
● Ask a friend/tester to pull and test
● Push to central repo, submit for merging
● If urgent work comes, stash or switch to another branch
39
Workflow
● [Admin] merge all incoming branches into a
release branch, test
● [Admin] Merge into master and deploy to
production
● Forking workflow – open source projects
● http://git-scm.com/docs/gitworkflows
40
UI & other tools
● Gitk – graphical UI for tree view of commits
● github.com – cloud server
● Gitosis – manage permissions
● Gitolite – manage authorizations at branch &
tag levels
41
Migrate from SVN/ClearCase
● Migrate a repo to Git
– Admin create git repo for deployment
– Devs continue to push to SVN
– Admin commits to local git and pushes it
– Make SVN read-only at migration cut-off
● Labels → Tags, Branch, History & commit
messages
● Commercial tools
42
Git internals
● Tracks patches not files
● Stored in BLOBS (binary large objects)
● Folders represented as trees
● Each tree has other trees or BLOBs – along with
meta data
● BLOBs expanded into files
● Immutable append only object database
● .git folder – refs, HEAD, ORIG_HEAD, obejcts
43
Git internals
● Any amount of data goes in → a fixed sized hash
comes out
● If inputs match, checksums match. If checksums
match, inputs match
● Very difficult to produce two inputs with the same
output. Very difficult to produce a desired target
checksum
● Commit IDs are hashes of commit patches
44
Git internals: Hash
● Git uses hashes for names
● Whenever Git saves a file
– It calculates the file's hash
– It stores the file under that hash
– The hash becomes the file's name
● Git never says “give me file stat.h”. Instead it says “give me
file 5b5beb89ba449a9271b3c34d44b529d2a2633235”
● Why? stat.h is ambiguous. Hash is never ambiguous. Also,
this completely defeats corruption and tampering
45
Git internals: Hash
● A bunch of data stored under its hash is called an object
● When the data is the contents of a file, the object is a blob
● To store a directory, Git writes out an object describing the
directory's contents. Its called a tree
100644 blob 3a6f56f8a15f5f96411c267a7428fcfeff6f9bcd foo
040000 tree e79566ab21a03dfac3fb4b479b24e3d9ff379d29 doc
100644 blob 22aa6ff4684a3080367c7bb5ec366fb3bd0364c6 bar
● A commit records the state of the entire repository at a particular moment
● Commits are tamper-proof
46
Listen
Think
Practice
47
You are welcome to reach out to me at
akmathur@gmail.com
Thanks!
Ad

More Related Content

What's hot (20)

Git
GitGit
Git
Majid Hajiloo
 
Git Presentation
Git PresentationGit Presentation
Git Presentation
Prem Aseem Jain
 
Git and Github
Git and GithubGit and Github
Git and Github
Wen-Tien Chang
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
聖文 鄭
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
Elli Kanal
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015
mwrather
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
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
 
Git 101 tutorial presentation
Git 101 tutorial presentationGit 101 tutorial presentation
Git 101 tutorial presentation
Terry Wang
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamental
Rajesh Kumar
 
Git advanced
Git advancedGit advanced
Git advanced
Peter Vandenabeele
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
Luigi De Russis
 
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
E Carter
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
Ignacio Martín
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
Kishor Kumar
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and Eclipse
Hüseyin Ergin
 
Git training
Git trainingGit training
Git training
Jérémy Gobet
 
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
Edureka!
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
聖文 鄭
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015
mwrather
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
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
 
Git 101 tutorial presentation
Git 101 tutorial presentationGit 101 tutorial presentation
Git 101 tutorial presentation
Terry Wang
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamental
Rajesh Kumar
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
Luigi De Russis
 
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
E Carter
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
Kishor Kumar
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and Eclipse
Hüseyin Ergin
 
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
Edureka!
 

Similar to Introduction to Git (20)

tech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptxtech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptx
ashishraulin
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
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
 
Git intro hands on windows with msysgit
Git intro hands on windows with msysgitGit intro hands on windows with msysgit
Git intro hands on windows with msysgit
Geshan Manandhar
 
Fundamentals and basics of Git and commands
Fundamentals and basics of Git and commandsFundamentals and basics of Git and commands
Fundamentals and basics of Git and commands
DivyanshGupta922023
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
Sebin Benjamin
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
Adam Culp
 
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
Git and GitHub Presentation of GDG on Campus UNSTPB
Git and GitHub Presentation of GDG on Campus UNSTPBGit and GitHub Presentation of GDG on Campus UNSTPB
Git and GitHub Presentation of GDG on Campus UNSTPB
AmaraCostachiu
 
Version control and GIT Primer
Version control and GIT PrimerVersion control and GIT Primer
Version control and GIT Primer
saadulde
 
Git Basics
Git BasicsGit Basics
Git Basics
Ryan Condron
 
Version Control Systems Software Engineering
Version Control Systems Software EngineeringVersion Control Systems Software Engineering
Version Control Systems Software Engineering
ssuser1c86e3
 
Brown bag sessions git workshop
Brown bag sessions git workshopBrown bag sessions git workshop
Brown bag sessions git workshop
Bishant Shrestha
 
Git and GitHub Workshop of GDG on Campus UNSTPB
Git and GitHub Workshop of GDG on Campus UNSTPBGit and GitHub Workshop of GDG on Campus UNSTPB
Git and GitHub Workshop of GDG on Campus UNSTPB
AmaraCostachiu
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
Nyros Technologies
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
 
14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx
GDSCGHRIETNagpur
 
01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
Edward Goikhman
 
Git with the flow
Git with the flowGit with the flow
Git with the flow
Dana White
 
Advanted git
Advanted git Advanted git
Advanted git
Sahil Gupta
 
tech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptxtech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptx
ashishraulin
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
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
 
Git intro hands on windows with msysgit
Git intro hands on windows with msysgitGit intro hands on windows with msysgit
Git intro hands on windows with msysgit
Geshan Manandhar
 
Fundamentals and basics of Git and commands
Fundamentals and basics of Git and commandsFundamentals and basics of Git and commands
Fundamentals and basics of Git and commands
DivyanshGupta922023
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
Sebin Benjamin
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
Adam Culp
 
Git and GitHub Presentation of GDG on Campus UNSTPB
Git and GitHub Presentation of GDG on Campus UNSTPBGit and GitHub Presentation of GDG on Campus UNSTPB
Git and GitHub Presentation of GDG on Campus UNSTPB
AmaraCostachiu
 
Version control and GIT Primer
Version control and GIT PrimerVersion control and GIT Primer
Version control and GIT Primer
saadulde
 
Version Control Systems Software Engineering
Version Control Systems Software EngineeringVersion Control Systems Software Engineering
Version Control Systems Software Engineering
ssuser1c86e3
 
Brown bag sessions git workshop
Brown bag sessions git workshopBrown bag sessions git workshop
Brown bag sessions git workshop
Bishant Shrestha
 
Git and GitHub Workshop of GDG on Campus UNSTPB
Git and GitHub Workshop of GDG on Campus UNSTPBGit and GitHub Workshop of GDG on Campus UNSTPB
Git and GitHub Workshop of GDG on Campus UNSTPB
AmaraCostachiu
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
 
Git with the flow
Git with the flowGit with the flow
Git with the flow
Dana White
 
Ad

Recently uploaded (20)

Salesforce Aged Complex Org Revitalization Process .pdf
Salesforce Aged Complex Org Revitalization Process .pdfSalesforce Aged Complex Org Revitalization Process .pdf
Salesforce Aged Complex Org Revitalization Process .pdf
SRINIVASARAO PUSULURI
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Adobe Illustrator Crack | Free Download & Install Illustrator
Adobe Illustrator Crack | Free Download & Install IllustratorAdobe Illustrator Crack | Free Download & Install Illustrator
Adobe Illustrator Crack | Free Download & Install Illustrator
usmanhidray
 
Xforce Keygen 64-bit AutoCAD 2025 Crack
Xforce Keygen 64-bit AutoCAD 2025  CrackXforce Keygen 64-bit AutoCAD 2025  Crack
Xforce Keygen 64-bit AutoCAD 2025 Crack
usmanhidray
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Salesforce Aged Complex Org Revitalization Process .pdf
Salesforce Aged Complex Org Revitalization Process .pdfSalesforce Aged Complex Org Revitalization Process .pdf
Salesforce Aged Complex Org Revitalization Process .pdf
SRINIVASARAO PUSULURI
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Adobe Illustrator Crack | Free Download & Install Illustrator
Adobe Illustrator Crack | Free Download & Install IllustratorAdobe Illustrator Crack | Free Download & Install Illustrator
Adobe Illustrator Crack | Free Download & Install Illustrator
usmanhidray
 
Xforce Keygen 64-bit AutoCAD 2025 Crack
Xforce Keygen 64-bit AutoCAD 2025  CrackXforce Keygen 64-bit AutoCAD 2025  Crack
Xforce Keygen 64-bit AutoCAD 2025 Crack
usmanhidray
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Ad

Introduction to Git

  • 2. Introductions ● Job description & Experience with Git ● Laptop, notebook & pen ● List your topics under “Make sure you cover”
  • 3. Introductions ● What's your target project? Job description? ● Experience level with any VCS ● Linux or Windows? ● Laptop, notebook & pen ● List your topics under “Make sure you cover”
  • 4. 4 Contents – session 1 ● Why version control ● DVCS ● History, characteristics ● Installation and config ● Hands on
  • 5. 5 Contents – session 2 ● Important Concepts ● Collaborate with Git ● Rewrite history ● Development help from Git
  • 6. 6 Contents – session 3 ● Debug with Git ● Working with remotes ● Advantages of Git – review ● Advanced commands
  • 7. 7 Contents – session 4 ● Best practices ● Workflows ● UI ● Migrating from SVN or Clearcase to Git ● Git Internals
  • 9. 9 Why version control ● History of code changes – your own & by others ● Collaborate: merge multiple changes in same file ● Revert ● Blame
  • 10. 10 DVCS ● No central repo ● Ops are fast – no server ● No network required - work offline. Whole copy of the repo available locally ● Alternatives DVCS – Mercurial, BitKeeper
  • 11. 11 Git's history ● Designed by Linus Torvalds in 2005 ● For speedy and distributed dev of Linux ● Git means “stupid person” ● Most widely used VCS currently ● Linux, POSIX, OS X, Windows
  • 12. 12 Characteristics ● Global commit IDs – SHA1 sig, non-sequential ● Tracks patches ● Lightweight branching ● Fast
  • 13. 13 Characteristics ● Good for – Large projects, large number of devs – Multiple releases – Multiple workflows ● Bad interface over an excellent technology – Non-intuitive command options – Not very good GUI
  • 14. 14 Install Git Linux apt-get install git-core yum install git Windows http://www.siteground.com/tutorials/git/win_installation.htm http://msysgit.github.io http://git-scm.org git help <command> Generate Public/Private Keys
  • 15. 15 Set up a repo ● New local project – git init ● On server: git init –bare – Omits working copy – .git added to folder by convention ● Get from server – git clone ● Cloud Hosted (github)
  • 16. 16 Setup $ git config $ git config --global user.name "Your Name" $ git config --global user.email [email protected] Edit ~/.gitconfig to add shortcuts & colours
  • 17. 17 Hands on Typical projects start by cloning a public repo or getting zip of source git clone git://github.com/akmathur/demo_app2 Make a small change Try common commands: git status git diff git add . git commit -m “[bugfix] handled zero input” git log, git log -p, git log --since=2016/01/15 git show HEAD^ git show HEAD~2
  • 19. 19 Important concepts Staging area - Build commits incrementally git add git diff –-cached git reset HEAD <file name> git add git rm
  • 20. 20 Important concepts Branching - easy to create, merge, destroy git branch <name> git branch git checkout <name> git branch -D <name> git merge <name> git log HEAD..<name>
  • 21. 21 Collaborate ● Branching – Work on same branch or share branch names – git push -u origin <branch-name> ● Share patches – git diff, git apply
  • 22. 22 Modify history git rebase -i <base commit> • Reorder commits, create linear history git revert • Undo by reversing a commit git reset • Undo by going back in history git commit –amend git checkout <filename> git reset HEAD <filename>
  • 23. 23 Development help Interactive add git add -i, git add -p Tagging git tag Ask git to ignore files .gitignore Stash git stash save “bug 2 in progress” git stash pop
  • 25. 25 Git basics review VCS vs DVCS Install and Setup Making a commit – staging area Common commands - log, diff, adding and removing files Branching, merging Modifying history – revert, reset, commit --amend, rebase Development help – stash, tag, add -p
  • 26. 26 Debug with Git Narrow down to last working version git bisect Who put in this line git blame
  • 27. 27 Rebase & Cherry-pick Move commits from a local branch into master git rebase <branch-name> Move only selected commits git cherry-pick <branch-name>
  • 28. 28 Working with remote repo git remote add origin <url> git remote, git remote show <name>, git remote remove <name> git fetch git pull origin <branch-name> git push -u origin <local-branch-name> ● Pull/Push can be done to any repo. Central is by convention only ● Remote branch names are origin/<branch-name>
  • 29. 29 Set up a remote repo cd /somewhere/on/hard/drive mkdir my_project.git cd my_project.git git init --bare cd /home/work/my_project git init # create some files # add all files e.g. *.cpp *.h git add * git commit -m "initial commit" git remote add origin /somewhere/on/hard/drive/my_project.git git push -u origin master
  • 30. 30 Collaboration ● Configure your remotes (default “origin” should always be there) ● Commit to local repo ● git pull (or git fetch and then merge) ● Resolve merge conflicts if any ● git push
  • 31. 31 Hands-on Exercises ● Someone removed a file. What did the file have when it was removed? ● Find how a file looked 2 commits ago? ● Two bug fixes were committed together in one commit. Separate them out in two different branches.
  • 32. 32 Hands-on Exercises ● Get a branch from your friend's repo but push it to the central repo as your branch ● Someone committed some changes but deleted some files by mistake in that commit. How will restore the deleted files while keeping rest of the changes?
  • 33. 33 Review Debug commands – git blame, git bisect Rebase & Cherry pick Remote repo – setup, pull, resolve merge conflicts, push
  • 35. 35 Advantages of Git ● Lightweight branching ● Modify History ● Collaboration ● Debugging ● Distributed development
  • 36. 36 Advanced commands ● git gc ● git prune ● git fsck ● git archive ● Hooks
  • 37. 37 Best practices ● Commit often, 1 line commit message ● Don't rebase after push ● Use branches liberally ● Don't fear mistakes – anything can be undone
  • 38. 38 Workflows Use cases: Enterprise, Central managed repo ● Get a bug or a feature ● Start a local branch ● Commit often, test, satisfy yourself ● Rebase and arrange commits ● Merge ● Ask a friend/tester to pull and test ● Push to central repo, submit for merging ● If urgent work comes, stash or switch to another branch
  • 39. 39 Workflow ● [Admin] merge all incoming branches into a release branch, test ● [Admin] Merge into master and deploy to production ● Forking workflow – open source projects ● http://git-scm.com/docs/gitworkflows
  • 40. 40 UI & other tools ● Gitk – graphical UI for tree view of commits ● github.com – cloud server ● Gitosis – manage permissions ● Gitolite – manage authorizations at branch & tag levels
  • 41. 41 Migrate from SVN/ClearCase ● Migrate a repo to Git – Admin create git repo for deployment – Devs continue to push to SVN – Admin commits to local git and pushes it – Make SVN read-only at migration cut-off ● Labels → Tags, Branch, History & commit messages ● Commercial tools
  • 42. 42 Git internals ● Tracks patches not files ● Stored in BLOBS (binary large objects) ● Folders represented as trees ● Each tree has other trees or BLOBs – along with meta data ● BLOBs expanded into files ● Immutable append only object database ● .git folder – refs, HEAD, ORIG_HEAD, obejcts
  • 43. 43 Git internals ● Any amount of data goes in → a fixed sized hash comes out ● If inputs match, checksums match. If checksums match, inputs match ● Very difficult to produce two inputs with the same output. Very difficult to produce a desired target checksum ● Commit IDs are hashes of commit patches
  • 44. 44 Git internals: Hash ● Git uses hashes for names ● Whenever Git saves a file – It calculates the file's hash – It stores the file under that hash – The hash becomes the file's name ● Git never says “give me file stat.h”. Instead it says “give me file 5b5beb89ba449a9271b3c34d44b529d2a2633235” ● Why? stat.h is ambiguous. Hash is never ambiguous. Also, this completely defeats corruption and tampering
  • 45. 45 Git internals: Hash ● A bunch of data stored under its hash is called an object ● When the data is the contents of a file, the object is a blob ● To store a directory, Git writes out an object describing the directory's contents. Its called a tree 100644 blob 3a6f56f8a15f5f96411c267a7428fcfeff6f9bcd foo 040000 tree e79566ab21a03dfac3fb4b479b24e3d9ff379d29 doc 100644 blob 22aa6ff4684a3080367c7bb5ec366fb3bd0364c6 bar ● A commit records the state of the entire repository at a particular moment ● Commits are tamper-proof
  • 47. 47 You are welcome to reach out to me at [email protected] Thanks!