SlideShare a Scribd company logo
Managing Files with GIT
Akshay Mathur
Ground Rules
• Post on FB and Twitter now
• Disturb Everyone during the
session
– Not by phone rings
– Not by local talks
– By more information and
questions
2@akshaymathu
Let’s Know Each Other
• Who does not code?
• How do you store files?
• Have you used VCS?
– Which one?
– What do you store?
– Repository size?
– What happens when you are not on network?
• Why are you attending?
@akshaymathu 3
Akshay Mathur
• Founding Team Member of
– ShopSocially (Enabling “social” for retailers)
– AirTight Neworks (Global leader of WIPS)
• 15+ years in IT industry
– Currently Principal Architect at ShopSocially
– Mostly worked with Startups
• From Conceptualization to Stabilization
• At different functions i.e. development, testing, release
• With multiple technologies
@akshaymathu 4
What is the issue
What if I don’t care?
Keeping Track of Changes
• Hope you get it right first time
• Hope you can remember the changes
• You will actually end up rewriting 
@akshaymathu 6
Organizing Backups
• Save the files/directories appending some
context (usually dates)
– Totally ad-hoc
– Only the owner knows where is what
– Hard to pick a version to go back to
– Prone to error
– No tools to help
@akshaymathu 7
Sharing Work
• When many people need to work on same file
– Work sequentially
– Overwrite other’s changes
– Keep track via emails
@akshaymathu 8
The Solution
Version Control System (VCS)
How VCS Help?
• Keeps track of changes
– Tells who change what and when
• Merges changes done by different people
– Detects and alerts if same thing is changed by
different people
• Allows comparing two versions
– Shows how information has grown
• Allows going back to previous version
@akshaymathu 10
VCS Terminology
• Repository
– Place where VCS stores files and its metadata
• Sandbox
– Place where files are available for editing
• Checkout
– Process of getting files from repository to sandbox
• Commit
– Process of putting files from sandbox to repository
@akshaymathu 11
Storage System
• Non-intrusive
– Everything is stored in
different folders/files
• Compact
– Incremental changes are
stored
– Different storage techniques
• RCS, BerkleyDB etc.
@akshaymathu 12
Versioning Scheme
• File Versioning
– Version number of only changed file is changed
• Repository Versioning
– Version number of entire repository changes
every time
• Version numbers can be
– A serial number
– Hash of the content
1.1 1.2 1.3 1.4 1.5
@akshaymathu 13
@akshaymathu 14
How VCS work
Managing Concurrency Optimistically
@akshaymathu 16
@akshaymathu 17
@akshaymathu 18
@akshaymathu 19
@akshaymathu 20
@akshaymathu 21
Types of VCS
Where is the repository?
Centralized
• CVS, SVN etc.
• Repository at only one central location
– Sandbox on every working machine
• Network is needed for every operation
– Can not work offline
• The repository has to be protected and backed
up
– Work stops if repository goes down
@akshaymathu 23
Centralized VCS
    
@akshaymathu 24
Centralized VCS Operations
@akshaymathu 25
Repository
Server Client
Sandbox
Checkout
Commit
Distributed
• Mercurial, Bitkeeper etc
• Repository on every machine
– Sandbox and repository are always together
• Network is needed only for repository sync
– Can work offline
• Backups are trivial
• Election of central repository by convention
@akshaymathu 26
Distributed VCS
@akshaymathu 27




Distributed VCS Operations
@akshaymathu 28
Repository
Remote Local
Sandbox
Pull
Push
Sandbox
Repository
Commit Checkout
@akshaymathu 29
Working with GIT
GIT
• Free
• Open Source
• Created by Linus Torvalds (Mr. Linux)
• First used for Linux Kernel
@akshaymathu 31
General Info
• Distributed
– All repositories hold same data/info
• Compact
– Low footprint
– Compact Repository
• Fast
– Quick operations
– Low Data Transfer
• Feature rich yet simple
• Intelligent
@akshaymathu 32
Hands on Practice
@akshaymathu 33
Creating Repository
• Init
– Initialize a new repository on local machine
• Creates a .git directory with subdirectories for
objects, refs/heads, refs/tags, and template files
• An initial HEAD file that references the HEAD of the
master branch is also created
git init <repository_name>
@akshaymathu 34
Adding New File
• Add
– Adds a new file into the list of tracked files
– A list of files (or wildcard) is accepted
– Commit is not automatic
git add <file_1> <file_2>
git add <file_*>
@akshaymathu 35
Editing the File
• No restriction from GIT
• Use your favorite editor
– Text files
• Vim, Notepad, Textpad, Eclipse, Visual
Studio, Dreamviewer etc.
– Binary Files
• Word, Excel, Powerpoint, Photoshop etc.
@akshaymathu 36
Removing Files
• Rm
– Removes file from the sandbox
– Remember to commit the change
git rm <file_name>
@akshaymathu 37
From Repository to Sandbox
• Checkout
– Gets file(s) from repository to sandbox
– Local changes of the files go away
git checkout <file_name>
@akshaymathu 38
Switching to Old Version
• Checkout
– Gets file(s) from repository to sandbox
• Commit ID of old version needs to be provided
– Sandbox gets detached and does not allow
commits
– Command fails if local changes are there in the file
git checkout <commitID>
@akshaymathu 39
Checking Current State
• Status
– Displays information about current state of
sandbox
• Branch name
• List of added, removed, modified and conflicted tracked
files
• List of untracked files
• Ignores files listed in .gitignore
git status
@akshaymathu 40
.gitignore
• A gitignore file specifies intentionally
untracked files that git should ignore
– Files already tracked by git are not affected
• Each line in a gitignore file specifies a pattern
• Wildcard can be used
@akshaymathu 41
Reviewing Changes
• Diff
– Shows difference between working copy of a file and
the copy in the repository
git diff
• Difftool
– Allows to use an external tool for viewing diff
git difftool –y –t xxdiff
• Log
– Lists all commit logs
git log
@akshaymathu 42
Saving into Repository
• Commit
– Stores current content of tracked files from
sandbox into repository
• A log message is required
• All files can be committed with –a option
• Selected files can be committed by providing list of files
git commit –am “<commit message>”
git commit –m “<commit message>” <file1>
<file2>
@akshaymathu 43
Commit Object
• Commit creates a commit object with the
current state of repository
– Author info and timestamp is recorded
– A new checkpoint is created
– New version number (commit ID) is assigned to
the checkpoint
• Commit ID is hash of the content in the commit
@akshaymathu 44
Marking a State of Repository
• Happens automatically with every commit
• Name of the state, the commit ID, is tough to
remember
– A simple name can be assigned
git tag <tag_name>
git tag <tag_name> <commitID>
@akshaymathu 45
@akshaymathu 46
Handling Emergencies
@akshaymathu 47
Saving Local Changes
• Stash
– Saves all local changes of sandbox
– Sandbox goes clean for coding and pushing a
hotfix
– Multiple stash can be created
git stash
@akshaymathu 48
Applying Saved Changes
• Stash apply
– Applies stashed changes back to the sandbox
– You can choose from multiple stashes
git stash apply
@akshaymathu 49
Sharing the Work
Distributed VCS Operations
@akshaymathu 51
Repository
Remote Local
Sandbox
Pull
Push
Sandbox
Repository
Commit Checkout
Clone
Getting Repository
• Clone
– Clones an existing remote repository, on local
machine, into a newly created directory
• Creates remote-tracking branches for each branch in
the cloned repository
• Checks out an initial branch into sandbox
• Default name of remote repository is ‘origin’
git clone <path_to_repository>
@akshaymathu 52
Getting Changes
• Pull
– Downloads objects and refs from remote
repository
– Merges with local repository
– Commits automatically
git pull
git pull origin master
@akshaymathu 53
Sending Changes
• Push
– Update remote repository with changes in local
repository
• Use --tags option for pushing tags
• Use –u option to push a new branch
– Uncommitted changes are not updated
git push origin master
@akshaymathu 54
55@akshaymathu
Diverging Streams
Why Diverging
• For parallel development
– A feature requiring long development time
• For experimenting new stuff
– Something we are not sure of
• Custom development
– For multiple clients from same codebase
@akshaymathu 57
Creating a Branch
• Branch
– Creates a new code stream reference in local
repository from specified point
• Checkout
– Checkout with –b option also creates a new
branch
• Latest checkpoint is used for branching by
default
• Any older commit ID can be specified
@akshaymathu 58
Branching
@akshaymathu 59
git branch <branch-name>
git checkout –b <branch_name>
git branch <branch-name> <start_point>
Branch Facts
• A branch named ‘master’ is always present in
the repository
• Name of a branch refers to a moving
checkpoint that is the latest commit on the
branch
– Branch name can be used in place of commit ID in
any command
@akshaymathu 60
Switching Branches
• Checkout
– Gets file(s) from repository to sandbox
• Branch name needs to be provided
– Command fails if local changes are there in the file
that are going to be overwritten
• Otherwise changed files remain there as is in sandbox
git checkout <branch_name>
@akshaymathu 61
Folding Back
• Merge
– Merges a branch into current branch
– Automatically commits, if no conflict
– Runs in local repository
• Requires push to update changes to remote
git merge <other_branch_name>
@akshaymathu 62
Merging
git merge <other_branch_name>
@akshaymathu 63
Conflicts
• If, at two places, changes are made in same
portion of a file
– GIT is not able to understand what to keep
– Puts both changes in the file
• Boundaries are marked in the file
• File is marked as conflicted
– Authors need to collaborate and fix
• Remember to commit after done
@akshaymathu 64
Moving Branch Point
• Rebase
– Forward-port local commits to the updated
upstream head
• All local commits in the current branch are saved to a
temporary area
• The current branch is reset to upstream
• The saved commits are then re-applied to the current
branch, one by one, in order
• Rebase stops in the middle in case of conflicts
• Rebase can be continued after resolving conflicts
@akshaymathu 65
Rebase
@akshaymathu 66
git rebase
<upstream_branch_name>
@akshaymathu 67
Best Practices
• Communicate with peers
• Write good commit log
• Never directly modify files repository directory
• Never share files using external means e.g.
email, ftp, ssh etc.
– Get the difference as needed
• Do not commit generated files
@akshaymathu 68
Branching Best Practices
• Merge a branch only into its upstream
• Keep ‘master’ untouched for hot fixes
• Have a branch (say ‘develop’) for out of
‘master’ for system and regression testing
• Create feature branches out of ‘develop’
@akshaymathu 69
Working with GUI
• Gui
– Launches a Graphical User Interface (GUI) for GIT
– Common operations can be performed
@akshaymathu 70
Thanks
@akshaymathu 71
Ad

More Related Content

What's hot (20)

Connect 2016-Move Your XPages Applications to the Fast Lane
Connect 2016-Move Your XPages Applications to the Fast LaneConnect 2016-Move Your XPages Applications to the Fast Lane
Connect 2016-Move Your XPages Applications to the Fast Lane
Howard Greenberg
 
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Thorben Janssen
 
Elements for an iOS Backend
Elements for an iOS BackendElements for an iOS Backend
Elements for an iOS Backend
Laurent Cerveau
 
Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
Adnan Sohail
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
WebStackAcademy
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 
Integrate Ruby on Rails with Avectra's NetFORUM xWeb API.
Integrate Ruby on Rails with Avectra's NetFORUM xWeb API.Integrate Ruby on Rails with Avectra's NetFORUM xWeb API.
Integrate Ruby on Rails with Avectra's NetFORUM xWeb API.
Thomas Vendetta
 
Hibernate Tips ‘n’ Tricks - 15 Tips to solve common problems
Hibernate Tips ‘n’ Tricks - 15 Tips to solve common problemsHibernate Tips ‘n’ Tricks - 15 Tips to solve common problems
Hibernate Tips ‘n’ Tricks - 15 Tips to solve common problems
Thorben Janssen
 
Handlebars & Require JS
Handlebars  & Require JSHandlebars  & Require JS
Handlebars & Require JS
Ivano Malavolta
 
COScheduler
COSchedulerCOScheduler
COScheduler
WO Community
 
Angular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and AuthorizationAngular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and Authorization
WebStackAcademy
 
Simplify AJAX using jQuery
Simplify AJAX using jQuerySimplify AJAX using jQuery
Simplify AJAX using jQuery
Siva Arunachalam
 
Medium TechTalk — iOS
Medium TechTalk — iOSMedium TechTalk — iOS
Medium TechTalk — iOS
jimmyatmedium
 
Tools that get you laid
Tools that get you laidTools that get you laid
Tools that get you laid
Swizec Teller
 
Simpler Core Data with RubyMotion
Simpler Core Data with RubyMotionSimpler Core Data with RubyMotion
Simpler Core Data with RubyMotion
Stefan Haflidason
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQuery
Gill Cleeren
 
jQuery
jQueryjQuery
jQuery
Ivano Malavolta
 
2011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 52011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 5
Daniel Fisher
 
HTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile appsHTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile apps
Ivano Malavolta
 
javaScript and jQuery
javaScript and jQueryjavaScript and jQuery
javaScript and jQuery
Mehrab Hossain
 
Connect 2016-Move Your XPages Applications to the Fast Lane
Connect 2016-Move Your XPages Applications to the Fast LaneConnect 2016-Move Your XPages Applications to the Fast Lane
Connect 2016-Move Your XPages Applications to the Fast Lane
Howard Greenberg
 
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Thorben Janssen
 
Elements for an iOS Backend
Elements for an iOS BackendElements for an iOS Backend
Elements for an iOS Backend
Laurent Cerveau
 
Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
Adnan Sohail
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
WebStackAcademy
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 
Integrate Ruby on Rails with Avectra's NetFORUM xWeb API.
Integrate Ruby on Rails with Avectra's NetFORUM xWeb API.Integrate Ruby on Rails with Avectra's NetFORUM xWeb API.
Integrate Ruby on Rails with Avectra's NetFORUM xWeb API.
Thomas Vendetta
 
Hibernate Tips ‘n’ Tricks - 15 Tips to solve common problems
Hibernate Tips ‘n’ Tricks - 15 Tips to solve common problemsHibernate Tips ‘n’ Tricks - 15 Tips to solve common problems
Hibernate Tips ‘n’ Tricks - 15 Tips to solve common problems
Thorben Janssen
 
Angular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and AuthorizationAngular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and Authorization
WebStackAcademy
 
Simplify AJAX using jQuery
Simplify AJAX using jQuerySimplify AJAX using jQuery
Simplify AJAX using jQuery
Siva Arunachalam
 
Medium TechTalk — iOS
Medium TechTalk — iOSMedium TechTalk — iOS
Medium TechTalk — iOS
jimmyatmedium
 
Tools that get you laid
Tools that get you laidTools that get you laid
Tools that get you laid
Swizec Teller
 
Simpler Core Data with RubyMotion
Simpler Core Data with RubyMotionSimpler Core Data with RubyMotion
Simpler Core Data with RubyMotion
Stefan Haflidason
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQuery
Gill Cleeren
 
2011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 52011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 5
Daniel Fisher
 
HTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile appsHTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile apps
Ivano Malavolta
 

Similar to Working with GIT (20)

Git basics
Git basicsGit basics
Git basics
Malihe Asemani
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
atishgoswami
 
Git and GitHub (1).pptx
Git and GitHub (1).pptxGit and GitHub (1).pptx
Git and GitHub (1).pptx
BetelAddisu
 
Git
GitGit
Git
Okba Mahdjoub
 
Learn Git form Beginners to Master
Learn Git form Beginners to MasterLearn Git form Beginners to Master
Learn Git form Beginners to Master
C. M. Abdullah Khan
 
Git
GitGit
Git
Keshavaprasad Bangalore Seshadri
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
 
Mini git tutorial
Mini git tutorialMini git tutorial
Mini git tutorial
Cristian Lucchesi
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
BigBlueHat
 
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
 
Git presentation to some coworkers some time ago
Git presentation to some coworkers some time agoGit presentation to some coworkers some time ago
Git presentation to some coworkers some time ago
Rodrigo Urubatan
 
Git 101
Git 101Git 101
Git 101
jayrparro
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
Kishor Kumar
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
Git
GitGit
Git
Surya Sreedevi Vedula
 
git.ppt.pdf
git.ppt.pdfgit.ppt.pdf
git.ppt.pdf
Roniel Lopez Alvarez
 
Git for folk who like GUIs
Git for folk who like GUIsGit for folk who like GUIs
Git for folk who like GUIs
Tim Osborn
 
Basic git
Basic gitBasic git
Basic git
Casper Chen
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamental
Rajesh Kumar
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
Vikram SV
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
atishgoswami
 
Git and GitHub (1).pptx
Git and GitHub (1).pptxGit and GitHub (1).pptx
Git and GitHub (1).pptx
BetelAddisu
 
Learn Git form Beginners to Master
Learn Git form Beginners to MasterLearn Git form Beginners to Master
Learn Git form Beginners to Master
C. M. Abdullah Khan
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
BigBlueHat
 
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
 
Git presentation to some coworkers some time ago
Git presentation to some coworkers some time agoGit presentation to some coworkers some time ago
Git presentation to some coworkers some time ago
Rodrigo Urubatan
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
Kishor Kumar
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
Git for folk who like GUIs
Git for folk who like GUIsGit for folk who like GUIs
Git for folk who like GUIs
Tim Osborn
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamental
Rajesh Kumar
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
Vikram SV
 
Ad

More from Akshay Mathur (16)

Documentation with Sphinx
Documentation with SphinxDocumentation with Sphinx
Documentation with Sphinx
Akshay Mathur
 
Kubernetes Journey of a Large FinTech
Kubernetes Journey of a Large FinTechKubernetes Journey of a Large FinTech
Kubernetes Journey of a Large FinTech
Akshay Mathur
 
Security and Observability of Application Traffic in Kubernetes
Security and Observability of Application Traffic in KubernetesSecurity and Observability of Application Traffic in Kubernetes
Security and Observability of Application Traffic in Kubernetes
Akshay Mathur
 
Enhanced Security and Visibility for Microservices Applications
Enhanced Security and Visibility for Microservices ApplicationsEnhanced Security and Visibility for Microservices Applications
Enhanced Security and Visibility for Microservices Applications
Akshay Mathur
 
Considerations for East-West Traffic Security and Analytics for Kubernetes En...
Considerations for East-West Traffic Security and Analytics for Kubernetes En...Considerations for East-West Traffic Security and Analytics for Kubernetes En...
Considerations for East-West Traffic Security and Analytics for Kubernetes En...
Akshay Mathur
 
Kubernetes as Orchestrator for A10 Lightning Controller
Kubernetes as Orchestrator for A10 Lightning ControllerKubernetes as Orchestrator for A10 Lightning Controller
Kubernetes as Orchestrator for A10 Lightning Controller
Akshay Mathur
 
Cloud Bursting with A10 Lightning ADS
Cloud Bursting with A10 Lightning ADSCloud Bursting with A10 Lightning ADS
Cloud Bursting with A10 Lightning ADS
Akshay Mathur
 
Shared Security Responsibility Model of AWS
Shared Security Responsibility Model of AWSShared Security Responsibility Model of AWS
Shared Security Responsibility Model of AWS
Akshay Mathur
 
Techniques for scaling application with security and visibility in cloud
Techniques for scaling application with security and visibility in cloudTechniques for scaling application with security and visibility in cloud
Techniques for scaling application with security and visibility in cloud
Akshay Mathur
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
Akshay Mathur
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
Akshay Mathur
 
Releasing Software Without Testing Team
Releasing Software Without Testing TeamReleasing Software Without Testing Team
Releasing Software Without Testing Team
Akshay Mathur
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
Akshay Mathur
 
Using Google App Engine Python
Using Google App Engine PythonUsing Google App Engine Python
Using Google App Engine Python
Akshay Mathur
 
Testing Single Page Webapp
Testing Single Page WebappTesting Single Page Webapp
Testing Single Page Webapp
Akshay Mathur
 
Mongo db
Mongo dbMongo db
Mongo db
Akshay Mathur
 
Documentation with Sphinx
Documentation with SphinxDocumentation with Sphinx
Documentation with Sphinx
Akshay Mathur
 
Kubernetes Journey of a Large FinTech
Kubernetes Journey of a Large FinTechKubernetes Journey of a Large FinTech
Kubernetes Journey of a Large FinTech
Akshay Mathur
 
Security and Observability of Application Traffic in Kubernetes
Security and Observability of Application Traffic in KubernetesSecurity and Observability of Application Traffic in Kubernetes
Security and Observability of Application Traffic in Kubernetes
Akshay Mathur
 
Enhanced Security and Visibility for Microservices Applications
Enhanced Security and Visibility for Microservices ApplicationsEnhanced Security and Visibility for Microservices Applications
Enhanced Security and Visibility for Microservices Applications
Akshay Mathur
 
Considerations for East-West Traffic Security and Analytics for Kubernetes En...
Considerations for East-West Traffic Security and Analytics for Kubernetes En...Considerations for East-West Traffic Security and Analytics for Kubernetes En...
Considerations for East-West Traffic Security and Analytics for Kubernetes En...
Akshay Mathur
 
Kubernetes as Orchestrator for A10 Lightning Controller
Kubernetes as Orchestrator for A10 Lightning ControllerKubernetes as Orchestrator for A10 Lightning Controller
Kubernetes as Orchestrator for A10 Lightning Controller
Akshay Mathur
 
Cloud Bursting with A10 Lightning ADS
Cloud Bursting with A10 Lightning ADSCloud Bursting with A10 Lightning ADS
Cloud Bursting with A10 Lightning ADS
Akshay Mathur
 
Shared Security Responsibility Model of AWS
Shared Security Responsibility Model of AWSShared Security Responsibility Model of AWS
Shared Security Responsibility Model of AWS
Akshay Mathur
 
Techniques for scaling application with security and visibility in cloud
Techniques for scaling application with security and visibility in cloudTechniques for scaling application with security and visibility in cloud
Techniques for scaling application with security and visibility in cloud
Akshay Mathur
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
Akshay Mathur
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
Akshay Mathur
 
Releasing Software Without Testing Team
Releasing Software Without Testing TeamReleasing Software Without Testing Team
Releasing Software Without Testing Team
Akshay Mathur
 
Using Google App Engine Python
Using Google App Engine PythonUsing Google App Engine Python
Using Google App Engine Python
Akshay Mathur
 
Testing Single Page Webapp
Testing Single Page WebappTesting Single Page Webapp
Testing Single Page Webapp
Akshay Mathur
 
Ad

Recently uploaded (20)

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
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
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
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
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
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
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
 
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
 
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
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
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.
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
#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
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
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
 
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
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
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
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
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
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
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
 
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
 
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
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
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.
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
#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
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
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
 

Working with GIT

  • 1. Managing Files with GIT Akshay Mathur
  • 2. Ground Rules • Post on FB and Twitter now • Disturb Everyone during the session – Not by phone rings – Not by local talks – By more information and questions 2@akshaymathu
  • 3. Let’s Know Each Other • Who does not code? • How do you store files? • Have you used VCS? – Which one? – What do you store? – Repository size? – What happens when you are not on network? • Why are you attending? @akshaymathu 3
  • 4. Akshay Mathur • Founding Team Member of – ShopSocially (Enabling “social” for retailers) – AirTight Neworks (Global leader of WIPS) • 15+ years in IT industry – Currently Principal Architect at ShopSocially – Mostly worked with Startups • From Conceptualization to Stabilization • At different functions i.e. development, testing, release • With multiple technologies @akshaymathu 4
  • 5. What is the issue What if I don’t care?
  • 6. Keeping Track of Changes • Hope you get it right first time • Hope you can remember the changes • You will actually end up rewriting  @akshaymathu 6
  • 7. Organizing Backups • Save the files/directories appending some context (usually dates) – Totally ad-hoc – Only the owner knows where is what – Hard to pick a version to go back to – Prone to error – No tools to help @akshaymathu 7
  • 8. Sharing Work • When many people need to work on same file – Work sequentially – Overwrite other’s changes – Keep track via emails @akshaymathu 8
  • 10. How VCS Help? • Keeps track of changes – Tells who change what and when • Merges changes done by different people – Detects and alerts if same thing is changed by different people • Allows comparing two versions – Shows how information has grown • Allows going back to previous version @akshaymathu 10
  • 11. VCS Terminology • Repository – Place where VCS stores files and its metadata • Sandbox – Place where files are available for editing • Checkout – Process of getting files from repository to sandbox • Commit – Process of putting files from sandbox to repository @akshaymathu 11
  • 12. Storage System • Non-intrusive – Everything is stored in different folders/files • Compact – Incremental changes are stored – Different storage techniques • RCS, BerkleyDB etc. @akshaymathu 12
  • 13. Versioning Scheme • File Versioning – Version number of only changed file is changed • Repository Versioning – Version number of entire repository changes every time • Version numbers can be – A serial number – Hash of the content 1.1 1.2 1.3 1.4 1.5 @akshaymathu 13
  • 15. How VCS work Managing Concurrency Optimistically
  • 22. Types of VCS Where is the repository?
  • 23. Centralized • CVS, SVN etc. • Repository at only one central location – Sandbox on every working machine • Network is needed for every operation – Can not work offline • The repository has to be protected and backed up – Work stops if repository goes down @akshaymathu 23
  • 24. Centralized VCS      @akshaymathu 24
  • 25. Centralized VCS Operations @akshaymathu 25 Repository Server Client Sandbox Checkout Commit
  • 26. Distributed • Mercurial, Bitkeeper etc • Repository on every machine – Sandbox and repository are always together • Network is needed only for repository sync – Can work offline • Backups are trivial • Election of central repository by convention @akshaymathu 26
  • 28. Distributed VCS Operations @akshaymathu 28 Repository Remote Local Sandbox Pull Push Sandbox Repository Commit Checkout
  • 31. GIT • Free • Open Source • Created by Linus Torvalds (Mr. Linux) • First used for Linux Kernel @akshaymathu 31
  • 32. General Info • Distributed – All repositories hold same data/info • Compact – Low footprint – Compact Repository • Fast – Quick operations – Low Data Transfer • Feature rich yet simple • Intelligent @akshaymathu 32
  • 34. Creating Repository • Init – Initialize a new repository on local machine • Creates a .git directory with subdirectories for objects, refs/heads, refs/tags, and template files • An initial HEAD file that references the HEAD of the master branch is also created git init <repository_name> @akshaymathu 34
  • 35. Adding New File • Add – Adds a new file into the list of tracked files – A list of files (or wildcard) is accepted – Commit is not automatic git add <file_1> <file_2> git add <file_*> @akshaymathu 35
  • 36. Editing the File • No restriction from GIT • Use your favorite editor – Text files • Vim, Notepad, Textpad, Eclipse, Visual Studio, Dreamviewer etc. – Binary Files • Word, Excel, Powerpoint, Photoshop etc. @akshaymathu 36
  • 37. Removing Files • Rm – Removes file from the sandbox – Remember to commit the change git rm <file_name> @akshaymathu 37
  • 38. From Repository to Sandbox • Checkout – Gets file(s) from repository to sandbox – Local changes of the files go away git checkout <file_name> @akshaymathu 38
  • 39. Switching to Old Version • Checkout – Gets file(s) from repository to sandbox • Commit ID of old version needs to be provided – Sandbox gets detached and does not allow commits – Command fails if local changes are there in the file git checkout <commitID> @akshaymathu 39
  • 40. Checking Current State • Status – Displays information about current state of sandbox • Branch name • List of added, removed, modified and conflicted tracked files • List of untracked files • Ignores files listed in .gitignore git status @akshaymathu 40
  • 41. .gitignore • A gitignore file specifies intentionally untracked files that git should ignore – Files already tracked by git are not affected • Each line in a gitignore file specifies a pattern • Wildcard can be used @akshaymathu 41
  • 42. Reviewing Changes • Diff – Shows difference between working copy of a file and the copy in the repository git diff • Difftool – Allows to use an external tool for viewing diff git difftool –y –t xxdiff • Log – Lists all commit logs git log @akshaymathu 42
  • 43. Saving into Repository • Commit – Stores current content of tracked files from sandbox into repository • A log message is required • All files can be committed with –a option • Selected files can be committed by providing list of files git commit –am “<commit message>” git commit –m “<commit message>” <file1> <file2> @akshaymathu 43
  • 44. Commit Object • Commit creates a commit object with the current state of repository – Author info and timestamp is recorded – A new checkpoint is created – New version number (commit ID) is assigned to the checkpoint • Commit ID is hash of the content in the commit @akshaymathu 44
  • 45. Marking a State of Repository • Happens automatically with every commit • Name of the state, the commit ID, is tough to remember – A simple name can be assigned git tag <tag_name> git tag <tag_name> <commitID> @akshaymathu 45
  • 48. Saving Local Changes • Stash – Saves all local changes of sandbox – Sandbox goes clean for coding and pushing a hotfix – Multiple stash can be created git stash @akshaymathu 48
  • 49. Applying Saved Changes • Stash apply – Applies stashed changes back to the sandbox – You can choose from multiple stashes git stash apply @akshaymathu 49
  • 51. Distributed VCS Operations @akshaymathu 51 Repository Remote Local Sandbox Pull Push Sandbox Repository Commit Checkout Clone
  • 52. Getting Repository • Clone – Clones an existing remote repository, on local machine, into a newly created directory • Creates remote-tracking branches for each branch in the cloned repository • Checks out an initial branch into sandbox • Default name of remote repository is ‘origin’ git clone <path_to_repository> @akshaymathu 52
  • 53. Getting Changes • Pull – Downloads objects and refs from remote repository – Merges with local repository – Commits automatically git pull git pull origin master @akshaymathu 53
  • 54. Sending Changes • Push – Update remote repository with changes in local repository • Use --tags option for pushing tags • Use –u option to push a new branch – Uncommitted changes are not updated git push origin master @akshaymathu 54
  • 57. Why Diverging • For parallel development – A feature requiring long development time • For experimenting new stuff – Something we are not sure of • Custom development – For multiple clients from same codebase @akshaymathu 57
  • 58. Creating a Branch • Branch – Creates a new code stream reference in local repository from specified point • Checkout – Checkout with –b option also creates a new branch • Latest checkpoint is used for branching by default • Any older commit ID can be specified @akshaymathu 58
  • 59. Branching @akshaymathu 59 git branch <branch-name> git checkout –b <branch_name> git branch <branch-name> <start_point>
  • 60. Branch Facts • A branch named ‘master’ is always present in the repository • Name of a branch refers to a moving checkpoint that is the latest commit on the branch – Branch name can be used in place of commit ID in any command @akshaymathu 60
  • 61. Switching Branches • Checkout – Gets file(s) from repository to sandbox • Branch name needs to be provided – Command fails if local changes are there in the file that are going to be overwritten • Otherwise changed files remain there as is in sandbox git checkout <branch_name> @akshaymathu 61
  • 62. Folding Back • Merge – Merges a branch into current branch – Automatically commits, if no conflict – Runs in local repository • Requires push to update changes to remote git merge <other_branch_name> @akshaymathu 62
  • 64. Conflicts • If, at two places, changes are made in same portion of a file – GIT is not able to understand what to keep – Puts both changes in the file • Boundaries are marked in the file • File is marked as conflicted – Authors need to collaborate and fix • Remember to commit after done @akshaymathu 64
  • 65. Moving Branch Point • Rebase – Forward-port local commits to the updated upstream head • All local commits in the current branch are saved to a temporary area • The current branch is reset to upstream • The saved commits are then re-applied to the current branch, one by one, in order • Rebase stops in the middle in case of conflicts • Rebase can be continued after resolving conflicts @akshaymathu 65
  • 68. Best Practices • Communicate with peers • Write good commit log • Never directly modify files repository directory • Never share files using external means e.g. email, ftp, ssh etc. – Get the difference as needed • Do not commit generated files @akshaymathu 68
  • 69. Branching Best Practices • Merge a branch only into its upstream • Keep ‘master’ untouched for hot fixes • Have a branch (say ‘develop’) for out of ‘master’ for system and regression testing • Create feature branches out of ‘develop’ @akshaymathu 69
  • 70. Working with GUI • Gui – Launches a Graphical User Interface (GUI) for GIT – Common operations can be performed @akshaymathu 70