SlideShare a Scribd company logo
GIT
By K. Ravi Rohith
CONTENTS
• INTRODUCTION TO GIT
• HISTORY OF GIT
• VERSION CONTROL SYSTEM
• GETTING STARTED TO GIT
• GIT UTILITY COMMANDS
• BRANCHING
• MERGING
• REBASE
• SUMMARY
INTRO TO GIT
• GIT is a Distributed Version Control System.
• It is a content addressable file system, used to track directory trees.
• It handles all the things like merging of source code and maintaining
versions.
• GIT is optimized for Complex Merges and Fast.
• It follows Trunk Base Development.
• It allows for code collaboration with anyone online.
GIT HISTORY
• Linus uses BitKeeper to manage Linux code
• In 2005, BitKeeper suddenly became unavailable.
• Linus decided to create a tool with Distributed Source Management
System.
• Linus Torvalds developed GIT in June 2005.
TERMINOLOGY
• DIRECTORY : A folder is used for storing multiple files.
• REPOSITORY : A collection of all the files and their history organized in folders,
branches, tags.
• CLONE : Act of copying a repository from a remote server.
• BRANCH : It is a pointer to a commit(save the files).
• MERGE : Combination of one or more branches into the current branch.
• ORIGIN : The default name of the remote repository.
• MASTER : It is just another branch, but is the default one which gets created.
• STAGE FILES : These are the files we have told GIT that are ready to committed.
• SNAPSHOT : In general is just the "entity" that git uses to store its data.
• INTEGRATORS : It can review and bring changes to reference code asynchronously to
central repository.
VERSION CONTROL SYSTEM
• Version Control System (VCS) is a software that helps software developers to work
together and maintain a complete history of their work.
• Version Control, also known as Revision Control or Source Control.
Functions of a Version Control System :
• Allows developers to work simultaneously.
• Maintains a history of every version.
• Does not allow overwriting each other’s changes.
Following are the types of Version Control System :
• Centralized version control system (CVCS).
• Distributed/Decentralized version control system (DVCS).
CENTRALIZED VERSION CONTROL SYSTEM
• Centralized version control system (CVCS) uses a central server to store all files and
enables team collaboration.
• “Committing” a change simply means recording the change in the central system
and Other programmers can then see this change.
• They can also pull down the change, and the version control tool will automatically
update the contents of any files that were changed.
• It is a Client-Server approach.
CENTRALIZED VERSION CONTROL WORKFLOW
When you’re working with a Centralized Version Control System, your
workflow for adding a new feature or fixing a bug in your project will
usually look something like this:
• Pull down any changes other people have made from the central server.
• Make your changes, and make sure they work properly.
• Commit your changes to the central server, so other programmers can
see them.
DISADVANTAGES OF CENTRALIZED VERSION CONTROL
• Merging of files or code is difficult.
• A single point of failure i.e., failure of the central server.
• Remote Server commits slow while transferring data.
• Unsolicited changes that may break your project.
DISTURBUTED VERSION CONTROL SYSTEM
• Distributed Version Control System (DVCS) is a form of version control that
allows software developers to work on a given project without requiring them
to share a common network.
• Distributed version control takes a peer to peer approach.
• It synchronizes repositories by exchanging patches (sets of changes) from
peer to peer.
Advantages of Distributed Version Control System
• Don’t require any common network
• DVCS is fast because it not rely on central server.
• In Implicit Backup, data present on any client side mirrors the repository,
hence it can be used in the event of a crash or disk corruption.
• Security is more. It uses a common cryptographic hash function called secure
hash function.
• Easy to create branches because DVCS is branch management system.
DVCS TERMINOLOGIES
• Local Repository – it is a private workplace
• Working Directory – the place where files are checked out.
• Blob – stands for Binary Large Object. Each version of a file is
represented by blob.
• Tree - Tree is an object, which represents a directory. It holds blobs as
well as other sub-directories.
• Revision - Revision represents the version of the source code. Revisions in Git
are represented by commits.
• Tags – It assigns a meaningful name with a specific version in the repository. It
is immutable.
GETTING STARTED
Git is a version control system for tracking changes in computer files and
coordinating work on those files among multiple people.
• Three trees of Git
– The HEAD
• last commit snapshot, next parent
– Index
• Proposed next commit snapshot
– Working directory
• Sandbox
WORKFLOW OF GIT
• Init a repo – To initialize the repository in GIT : Git init
• Edit files
• Stage the changes
• Review your changes
• Commit the changes
Getting Started
• A basic workflow
– Edit files
– Stage the changes
– Review your changes
– Commit the changes
Use your favorite editor
15
Getting Started
• A basic workflow
– Edit files
– Stage the changes
– Review your changes
– Commit the changes
• Git add filename
16
• A basic workflow
– Edit files
– Stage the changes
– Review your changes
– Commit the changes
• Git status
17
Getting Started
Getting Started
• A basic workflow
– Edit files
– Stage the changes
– Review your changes
– Commit the changes
Git commit
18
Other GIT Utility commands
• git gc – garbage collector (run it when the /.git/ directory
takes too much space).
• git stash – save/restore the state of the working copy
and index.
• git clean – clean the working tree.
• git bisect – locating which commit introduced a bug.
• git cherry-pick – merging a single commit.
• git revert – canceling a previous commit
BRANCHING
• It is a pointer to a commit(save the files).
• The default branch name in Git is master.
• ‘git branch’ command used for create, rename, list and delete files.
20
USAGE
• git branch – List all of the branches in your repository.
• git branch <branch> – To create a new branch called <branch>.
• git branch -d <branch> – To delete the branch.
• git branch -m <branch> – To rename the current branch.
• git branch –merged – To display all branches that are already merged.
• git branch –a –color – it will be shown in appropriate colors to all
branches.
git branch -a --color
USAGE
• Git checkout
– lets you navigate between the
branches created by git branch.
MERGE
• Combining one ore more branches into the current branch.
• Allows changes from other branches to be integrated into the current
work history
• Merge only changes the workspace.
• If we commit in branch, other branches not affected
Features
– Fast Forward Merge
– 3 way Merge
23
24
MERGING
EXAMPLE Adding new branch to experiment
25
Committing the branch to repository Finally it navigates all the branches
in directory.
MERGING - CONFLICTS
• When merging, if there are conflicts - need to solve them.
• After solving, need to “add” the changes and commit the merged
workspace.
Working with remote Local file system
• Pros
– Simple
– Support existing access control
– NFS enabled
• Cons
– Public share is difficult to set up
– Slow on top of NFS
27
Working with remote GIT
• Pros
– Fastest protocol
– Allow public anonymous access
• Cons
– Lack of authentication
– Difficult to set up
28
Working With Remote
• Remote branching
– Branch on remote are different
from local branch
– Git fetch origin to get remote
changes
– Git pull origin try to fetch
remote changes and merge it
onto current branch.
– Git push means share your work
done on branch to remote
29
REBASE
• Instead of merging, replays set of changes on top of another branch
• Affects the “rebased” branch only
• Very useful to remove history clutter
• Simple rule, use locally only and for branches which you will never
share
SUMMARY
• Git is complex, but flexible and powerful.
• Git supports distributed teams very well.
• Due to it’s flexibility, every team needs to decide on the workflow which
works best for it.
THANK YOU

More Related Content

PPTX
GIT In Detail
PDF
Git training v10
PPTX
Git - Basic Crash Course
KEY
Introduction To Git
PDF
Learn O11y from Grafana ecosystem.
PPTX
Intro to git and git hub
PPTX
Introduction to Git and GitHub Part 1
PPTX
Introduction git
GIT In Detail
Git training v10
Git - Basic Crash Course
Introduction To Git
Learn O11y from Grafana ecosystem.
Intro to git and git hub
Introduction to Git and GitHub Part 1
Introduction git

What's hot (20)

PPTX
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
PPTX
GIT presentation
PDF
Introduction to Git and GitHub
PPTX
Git 101 for Beginners
PPTX
Git One Day Training Notes
PDF
MyBatisとMyBatis Generatorの話
PDF
Docker composeで開発環境をメンバに配布せよ
PPTX
Git and GitHub
PPT
Git workflows presentation
PPSX
CI-CD Jenkins, GitHub Actions, Tekton
PDF
Trunk based development for Beginners
PDF
CD using ArgoCD(KnolX).pdf
PDF
Trunk-Based Development
PDF
Introduction to Github Actions
PDF
Git & GitHub WorkShop
PPTX
Devops and git basics
PDF
Git and Github
PDF
Docker道場オンライン#1 Docker基礎概念と用語の理解
PDF
コンテナの作り方「Dockerは裏方で何をしているのか?」
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
GIT presentation
Introduction to Git and GitHub
Git 101 for Beginners
Git One Day Training Notes
MyBatisとMyBatis Generatorの話
Docker composeで開発環境をメンバに配布せよ
Git and GitHub
Git workflows presentation
CI-CD Jenkins, GitHub Actions, Tekton
Trunk based development for Beginners
CD using ArgoCD(KnolX).pdf
Trunk-Based Development
Introduction to Github Actions
Git & GitHub WorkShop
Devops and git basics
Git and Github
Docker道場オンライン#1 Docker基礎概念と用語の理解
コンテナの作り方「Dockerは裏方で何をしているのか?」
Ad

Similar to GIT INTRODUCTION (20)

PPTX
PDF
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
PPT
Introduction to git
PPTX
the Version Control systemlocalized.pptx
PPTX
Git Basics for Software Version Management
PDF
Git SVN Migrate Reasons
PPTX
Version Control with Git
PDF
Introduction to git
PPTX
Git GitHub jsdbcghsvchjsbcmshg cv ddcsd cjhsbdcjhbdscbc gs cgsvcsbcdbdkjcbsdk...
PPTX
Mini-training: Let’s Git It!
PPTX
Git theory
PPTX
Essential git for developers
PPTX
Introduction to git hub
PDF
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
PPTX
Git 101
PPTX
Svn vs mercurial vs github
PPTX
Slide set 7 (Source Code Management History Overview) - Copy.pptx
PPTX
Git Session 2K23.pptx
PPT
Git 101 - Crash Course in Version Control using Git
PDF
SQL Server DevOps Jumpstart
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Introduction to git
the Version Control systemlocalized.pptx
Git Basics for Software Version Management
Git SVN Migrate Reasons
Version Control with Git
Introduction to git
Git GitHub jsdbcghsvchjsbcmshg cv ddcsd cjhsbdcjhbdscbc gs cgsvcsbcdbdkjcbsdk...
Mini-training: Let’s Git It!
Git theory
Essential git for developers
Introduction to git hub
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Git 101
Svn vs mercurial vs github
Slide set 7 (Source Code Management History Overview) - Copy.pptx
Git Session 2K23.pptx
Git 101 - Crash Course in Version Control using Git
SQL Server DevOps Jumpstart
Ad

Recently uploaded (20)

PPTX
A Presentation on Artificial Intelligence
PPT
Teaching material agriculture food technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Unlocking AI with Model Context Protocol (MCP)
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
KodekX | Application Modernization Development
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation theory and applications.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Approach and Philosophy of On baking technology
A Presentation on Artificial Intelligence
Teaching material agriculture food technology
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Reach Out and Touch Someone: Haptics and Empathic Computing
Per capita expenditure prediction using model stacking based on satellite ima...
MYSQL Presentation for SQL database connectivity
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Unlocking AI with Model Context Protocol (MCP)
The AUB Centre for AI in Media Proposal.docx
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
20250228 LYD VKU AI Blended-Learning.pptx
KodekX | Application Modernization Development
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation theory and applications.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Approach and Philosophy of On baking technology

GIT INTRODUCTION

  • 1. GIT By K. Ravi Rohith
  • 2. CONTENTS • INTRODUCTION TO GIT • HISTORY OF GIT • VERSION CONTROL SYSTEM • GETTING STARTED TO GIT • GIT UTILITY COMMANDS • BRANCHING • MERGING • REBASE • SUMMARY
  • 3. INTRO TO GIT • GIT is a Distributed Version Control System. • It is a content addressable file system, used to track directory trees. • It handles all the things like merging of source code and maintaining versions. • GIT is optimized for Complex Merges and Fast. • It follows Trunk Base Development. • It allows for code collaboration with anyone online.
  • 4. GIT HISTORY • Linus uses BitKeeper to manage Linux code • In 2005, BitKeeper suddenly became unavailable. • Linus decided to create a tool with Distributed Source Management System. • Linus Torvalds developed GIT in June 2005.
  • 5. TERMINOLOGY • DIRECTORY : A folder is used for storing multiple files. • REPOSITORY : A collection of all the files and their history organized in folders, branches, tags. • CLONE : Act of copying a repository from a remote server. • BRANCH : It is a pointer to a commit(save the files). • MERGE : Combination of one or more branches into the current branch. • ORIGIN : The default name of the remote repository. • MASTER : It is just another branch, but is the default one which gets created. • STAGE FILES : These are the files we have told GIT that are ready to committed. • SNAPSHOT : In general is just the "entity" that git uses to store its data. • INTEGRATORS : It can review and bring changes to reference code asynchronously to central repository.
  • 6. VERSION CONTROL SYSTEM • Version Control System (VCS) is a software that helps software developers to work together and maintain a complete history of their work. • Version Control, also known as Revision Control or Source Control. Functions of a Version Control System : • Allows developers to work simultaneously. • Maintains a history of every version. • Does not allow overwriting each other’s changes. Following are the types of Version Control System : • Centralized version control system (CVCS). • Distributed/Decentralized version control system (DVCS).
  • 7. CENTRALIZED VERSION CONTROL SYSTEM • Centralized version control system (CVCS) uses a central server to store all files and enables team collaboration. • “Committing” a change simply means recording the change in the central system and Other programmers can then see this change. • They can also pull down the change, and the version control tool will automatically update the contents of any files that were changed. • It is a Client-Server approach.
  • 8. CENTRALIZED VERSION CONTROL WORKFLOW When you’re working with a Centralized Version Control System, your workflow for adding a new feature or fixing a bug in your project will usually look something like this: • Pull down any changes other people have made from the central server. • Make your changes, and make sure they work properly. • Commit your changes to the central server, so other programmers can see them.
  • 9. DISADVANTAGES OF CENTRALIZED VERSION CONTROL • Merging of files or code is difficult. • A single point of failure i.e., failure of the central server. • Remote Server commits slow while transferring data. • Unsolicited changes that may break your project.
  • 10. DISTURBUTED VERSION CONTROL SYSTEM • Distributed Version Control System (DVCS) is a form of version control that allows software developers to work on a given project without requiring them to share a common network. • Distributed version control takes a peer to peer approach. • It synchronizes repositories by exchanging patches (sets of changes) from peer to peer.
  • 11. Advantages of Distributed Version Control System • Don’t require any common network • DVCS is fast because it not rely on central server. • In Implicit Backup, data present on any client side mirrors the repository, hence it can be used in the event of a crash or disk corruption. • Security is more. It uses a common cryptographic hash function called secure hash function. • Easy to create branches because DVCS is branch management system.
  • 12. DVCS TERMINOLOGIES • Local Repository – it is a private workplace • Working Directory – the place where files are checked out. • Blob – stands for Binary Large Object. Each version of a file is represented by blob. • Tree - Tree is an object, which represents a directory. It holds blobs as well as other sub-directories. • Revision - Revision represents the version of the source code. Revisions in Git are represented by commits. • Tags – It assigns a meaningful name with a specific version in the repository. It is immutable.
  • 13. GETTING STARTED Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. • Three trees of Git – The HEAD • last commit snapshot, next parent – Index • Proposed next commit snapshot – Working directory • Sandbox
  • 14. WORKFLOW OF GIT • Init a repo – To initialize the repository in GIT : Git init • Edit files • Stage the changes • Review your changes • Commit the changes
  • 15. Getting Started • A basic workflow – Edit files – Stage the changes – Review your changes – Commit the changes Use your favorite editor 15
  • 16. Getting Started • A basic workflow – Edit files – Stage the changes – Review your changes – Commit the changes • Git add filename 16
  • 17. • A basic workflow – Edit files – Stage the changes – Review your changes – Commit the changes • Git status 17 Getting Started
  • 18. Getting Started • A basic workflow – Edit files – Stage the changes – Review your changes – Commit the changes Git commit 18
  • 19. Other GIT Utility commands • git gc – garbage collector (run it when the /.git/ directory takes too much space). • git stash – save/restore the state of the working copy and index. • git clean – clean the working tree. • git bisect – locating which commit introduced a bug. • git cherry-pick – merging a single commit. • git revert – canceling a previous commit
  • 20. BRANCHING • It is a pointer to a commit(save the files). • The default branch name in Git is master. • ‘git branch’ command used for create, rename, list and delete files. 20
  • 21. USAGE • git branch – List all of the branches in your repository. • git branch <branch> – To create a new branch called <branch>. • git branch -d <branch> – To delete the branch. • git branch -m <branch> – To rename the current branch. • git branch –merged – To display all branches that are already merged. • git branch –a –color – it will be shown in appropriate colors to all branches. git branch -a --color
  • 22. USAGE • Git checkout – lets you navigate between the branches created by git branch.
  • 23. MERGE • Combining one ore more branches into the current branch. • Allows changes from other branches to be integrated into the current work history • Merge only changes the workspace. • If we commit in branch, other branches not affected Features – Fast Forward Merge – 3 way Merge 23
  • 24. 24 MERGING EXAMPLE Adding new branch to experiment
  • 25. 25 Committing the branch to repository Finally it navigates all the branches in directory.
  • 26. MERGING - CONFLICTS • When merging, if there are conflicts - need to solve them. • After solving, need to “add” the changes and commit the merged workspace.
  • 27. Working with remote Local file system • Pros – Simple – Support existing access control – NFS enabled • Cons – Public share is difficult to set up – Slow on top of NFS 27
  • 28. Working with remote GIT • Pros – Fastest protocol – Allow public anonymous access • Cons – Lack of authentication – Difficult to set up 28
  • 29. Working With Remote • Remote branching – Branch on remote are different from local branch – Git fetch origin to get remote changes – Git pull origin try to fetch remote changes and merge it onto current branch. – Git push means share your work done on branch to remote 29
  • 30. REBASE • Instead of merging, replays set of changes on top of another branch • Affects the “rebased” branch only • Very useful to remove history clutter • Simple rule, use locally only and for branches which you will never share
  • 31. SUMMARY • Git is complex, but flexible and powerful. • Git supports distributed teams very well. • Due to it’s flexibility, every team needs to decide on the workflow which works best for it.