SlideShare a Scribd company logo
1 of 42
Download to read offline
Git
An intro to Git Source Control Management
What is Git?

Distributed version control system
Linus Torvalds - to track linux kernel development
Free and open source
Designed to handle small/large projects with speed and efficiency
Fast branching and merging
Why source control?
Faster development
Archive of all code changes over time
Compare changes and revert to old release
Accountability
Conserve disk space
Good for you
Distributed vs Centralized
The Basics
Installing git
• To initialize git directory
•   $ git init




• Start version controlling existing files
•   $ git add *.php *.inc *.html *.tpl

•   $ git commit -m ‘Initial project version’




• Cloning an existing repository
•   $ git clone ssh://clickindia@192.168.0.77/home/clickindia/public_html/clickindia
Basic git workflow




• You modify files in your working directory
• You stage files adding snapshot of them to staging area
• You do a commit which takes the files in staging area and
 stores the snapshot permanently
Changes in repository
To check status of your files
Modifying files
Tracking new files
Removing files
Staging modified files
Committing files
Ignoring files
Example of gitignore
$ cat .gitignore
 *.[oa]
 *~
 *.a       # no .a files
 !lib.a    # but do track lib.a, even though you're ignoring .a files above
 /TODO     # only ignore the root TODO file, not subdir/TODO
 build/    # ignore all files in the build/ directory
 doc/*.txt # ignore doc/notes.txt, but not doc/server/arch.txt
Viewing staged and
    unstaged changes
git status
git diff   (Compares working directory with staging area)


git diff --staged
git diff HEAD
git diff v1.0 v1.1
git diff master adposting
Branching
$ git add README test.rb LICENSE
$ git commit -m 'initial commit of my project'




    Created on commit              Created on add
Branching
Branching
Creating new branch
$ git branch testing
Current branch
Switching branch
$ git checkout testing
Significance of branch
$ vim test.php
$ git commit -am “made a change”
Significance of branch
$ git checkout master
Significance of branch
$ vim test.php
$ git commit -am “made a change”
Basic branching and merging
• Create a new feature branch
• Do some work in that branch
Critical issue in production
• Revert back to production branch
• Create a new branch to add the hotfix
• After testing, merge the hotfix branch and push to
  production

• Switch back to your original issue and continue
Basic branching and merging


$ git checkout -b iss53
Switched to a new branch "iss53"
Basic branching and merging
$ vi index.html
$ git commit -a -m 'added a new footer [issue 53]'
Basic branching and merging
Issue in production
$ git checkout master
Switched to branch “master”
$ git checkout -b ‘hotfix’
Switched to a new branch “hotfix”
$ vim index.html
$ git commit -am ‘fixed a broken email address’
[hotfix]: created 3a0874c: "fixed the broken email address"
 1 files changed, 0 insertions(+), 1 deletions(-)
Basic branching and merging
$ git checkout master
$ git merge --no-ff hotfix
Updating f42c576..3a0874c
 README |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)




 $ git branch -d hotfix
 Deleted branch hotfix (3a0874c).
Basic branching and merging
$ git checkout iss53
Switched to branch "iss53"
$ vim index.html
$ git commit -a -m 'finished the new footer [issue 53]'
[iss53]: created ad82d7a: "finished the new footer [issue 53]"
 1 files changed, 1 insertions(+), 0 deletions(-)
Basic branching and merging
$ git checkout master
$ git merge iss53
Merge made by recursive.
 README |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Basic branching and merging




$ git branch -d iss53
Branch management

$   git   branch                 #   Shows all the active branches
$   git   branch   -v            #   Shows last commit on each branch
$   git   branch   --merged      #   Shows which branches are merged with the branch you are on
$   git   branch   --no-merged   #   Shows all branches that contain work you haven’t merged
$   git   branch   -d testing    #   To delete a branch. Will fail if the branch is not yet merged
Remote branches
• Remote branches are references to the state
 of branches on your remote repositories
Remote branches
Remote branches
$ git fetch origin     # Fetches any data you don’t have from remote ‘origin’ repository
$ git fetch origin master    # Fetches data only from ‘master’ branch
$ git pull origin     # Fetches any data you don’t have and merges it with local branch
$ git pull origin master # Fetches data from master and merges it with local master branch
$ git push origin develop # Pushes data from local ‘develop’ branch to remote ‘develop’ branch
$ git push origin develop:release # Pushes data from local ‘develop’ branch to remote ‘release’ branch


                                           git fetch origin
Remotes
$ git remote
Origin

$ git remote -v
Origin ssh://clickindia@192.168.0.77/home/clickindia/public_html/clickindia

$ git remote add test ssh://clickindia@test.clickindia.com/home/clickindia/public_html....

$ git remote rm origin
Gist of git
Git branching model
How will we work?
                                pull
                  master                      master                master

                                                          pull
                  develop
                                push           release




               Development                  Test server          Production
               192.168.0.77




Developer 1   Developer 2     Developer 3
Tagging and release
Once the code is merged into master production
  $ git tag -a v1.0.1      # applies v1.0.1 tag to current commit

  $ git tag                # To list all tags

  $ git tag -1 ‘v1.4.2*‘   # List all tags starting with 1.4.2

  $ git tag -a v1.0.1 -m ‘my version 1.0.1’

  $ git show v1.4

   tag v1.4
   Tagger: Scott Chacon <schacon@gee-mail.com>
   Date:    Mon Feb 9 14:45:11 2009 -0800
   my version 1.4
   commit 15027957951b64cf874c3557a0f3547bd83b3ff6
   Merge: 4a447f7... a6b4c97...
   Author: Scott Chacon <schacon@gee-mail.com>
   Date:   Sun Feb 8 19:02:46 2009 -0800
        Merge branch 'experiment'
Tagging
Tagging later
 $ git log --pretty=oneline
 15027957951b64cf874c3557a0f3547bd83b3ff6   Merge branch 'experiment'
 a6b4c97498bd301d84096da251c98a07c7723e65   beginning write support
 0d52aaab4479697da7686c15f77a3d64d9165190   one more thing
 6d52a271eda8725415634dd79daabbc4d9b6008e   Merge branch 'experiment'
 0b7434d86859cc7b8c3d5e1dddfed66ff742fcbc   added a commit function
 4682c3261057305bdd616e23b64b0857d832627b   added a todo file
 166ae0c4d3f420721acbb115cc33848dfcc2121a   started write support
 9fceb02d0ae598e95dc970b74767f19372d61af8   updated rakefile
 964f16d36dfccde844893cac5b347e7b3d44abbc   commit the todo
 8a5cbc430f1a9c3d00faaeffd07798508422908a   updated readme




 $ git tag -a v1.2 9fceb02
Tagging
Everyday commands
Working on a new feature
$ git pull origin develop

$ git checkout -b adposting

.....did development work.....

$ git commit -am ‘Created new ad posting form’

$ git push origin adposting

......tested feature on development server.....

$ git checkout develop

$ git merge --no-ff adposting

$ git push origin develop:release-v1.1.2 (push to test server as release-v1.1.2

.........fix testing bugs on release v1.1.2.......

$ git fetch origin release-v1.1.2 ( on production only done by sysadmin )

$ git checkout master

$ git merge --no-ff release-v.1.1.2

$ git tag -am v1.1.2 ‘released version v1.1.2’
Everyday commands
Working on a hotfix
$ git pull origin master

$ git checkout -b hotfixv1.1.1 master

.....fixed bug on test server.....

$ git commit -am ‘fixed e-mail address on contact page’

....... Tested by deepak ........

$ git fetch origin hotfixv1.1.1 ( on production only done by sysadmin )

...... Check if already on master....if not $ git checkout master

$ git merge --no-ff hotfixv1.1.1

$ git tag -am v1.1.1 ‘released version v1.1.1’

$ git pull origin master ( on test and development servers)
Version numbering


                v0.0.0
Major release                    Hot fixes


                Minor releases
References

• Progit.org -- a complete book on git
• Gitref.org -- A very simple reference of all commands

More Related Content

What's hot

Gitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeGitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeTeerapat Khunpech
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
Learning git
Learning gitLearning git
Learning gitSid Anand
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An IntroductionBehzad Altaf
 
Présentation Git & GitHub
Présentation Git & GitHubPrésentation Git & GitHub
Présentation Git & GitHubThibault Vlacich
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash CourseNilay Binjola
 
GitHub Actions in action
GitHub Actions in actionGitHub Actions in action
GitHub Actions in actionOleksii Holub
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewRueful Robin
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHubJames Gray
 
DevOps with GitHub Actions
DevOps with GitHub ActionsDevOps with GitHub Actions
DevOps with GitHub ActionsNilesh Gule
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow IntroductionDavid Paluy
 

What's hot (20)

Gitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeGitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTree
 
git and github
git and githubgit and github
git and github
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Learning git
Learning gitLearning git
Learning git
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Overview of github
Overview of githubOverview of github
Overview of github
 
Présentation Git & GitHub
Présentation Git & GitHubPrésentation Git & GitHub
Présentation Git & GitHub
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
GitHub Actions in action
GitHub Actions in actionGitHub Actions in action
GitHub Actions in action
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Tutorial Git
Tutorial GitTutorial Git
Tutorial Git
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
DevOps with GitHub Actions
DevOps with GitHub ActionsDevOps with GitHub Actions
DevOps with GitHub Actions
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow Introduction
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 

Similar to Git basics

Get going with_git_ppt
Get going with_git_pptGet going with_git_ppt
Get going with_git_pptMiraz Al-Mamun
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
Lets Git Together
Lets Git TogetherLets Git Together
Lets Git TogetherRakesh Jha
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.comdropsolid
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in UnityRifauddin Tsalitsy
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Codemotion
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmdsrinathcox
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use ItDaniel Kummer
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlBecky Todd
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With GitHoffman Lab
 
Git development workflow
Git development workflowGit development workflow
Git development workflowSankar Suda
 

Similar to Git basics (20)

Get going with_git_ppt
Get going with_git_pptGet going with_git_ppt
Get going with_git_ppt
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Git101
Git101Git101
Git101
 
Lets Git Together
Lets Git TogetherLets Git Together
Lets Git Together
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Gitflow
GitflowGitflow
Gitflow
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 
簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
Git presentation
Git presentationGit presentation
Git presentation
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
 
Git development workflow
Git development workflowGit development workflow
Git development workflow
 
Working with Git
Working with GitWorking with Git
Working with Git
 

More from Amit Sawhney

Spotify India Entry
Spotify India EntrySpotify India Entry
Spotify India EntryAmit Sawhney
 
FieldDay_Sonica_Sapient
FieldDay_Sonica_SapientFieldDay_Sonica_Sapient
FieldDay_Sonica_SapientAmit Sawhney
 
The math-behind-ab-testing
The math-behind-ab-testingThe math-behind-ab-testing
The math-behind-ab-testingAmit Sawhney
 
Improving email open rates
Improving email open ratesImproving email open rates
Improving email open ratesAmit Sawhney
 

More from Amit Sawhney (7)

Spotify India Entry
Spotify India EntrySpotify India Entry
Spotify India Entry
 
FieldDay_Sonica_Sapient
FieldDay_Sonica_SapientFieldDay_Sonica_Sapient
FieldDay_Sonica_Sapient
 
Tools I Carry
Tools I CarryTools I Carry
Tools I Carry
 
The math-behind-ab-testing
The math-behind-ab-testingThe math-behind-ab-testing
The math-behind-ab-testing
 
Improving email open rates
Improving email open ratesImproving email open rates
Improving email open rates
 
Investing early
Investing earlyInvesting early
Investing early
 
Scrum
ScrumScrum
Scrum
 

Recently uploaded

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Recently uploaded (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

Git basics

  • 1. Git An intro to Git Source Control Management
  • 2. What is Git? Distributed version control system Linus Torvalds - to track linux kernel development Free and open source Designed to handle small/large projects with speed and efficiency Fast branching and merging
  • 3. Why source control? Faster development Archive of all code changes over time Compare changes and revert to old release Accountability Conserve disk space Good for you
  • 6. Installing git • To initialize git directory • $ git init • Start version controlling existing files • $ git add *.php *.inc *.html *.tpl • $ git commit -m ‘Initial project version’ • Cloning an existing repository • $ git clone ssh://clickindia@192.168.0.77/home/clickindia/public_html/clickindia
  • 7. Basic git workflow • You modify files in your working directory • You stage files adding snapshot of them to staging area • You do a commit which takes the files in staging area and stores the snapshot permanently
  • 8. Changes in repository To check status of your files Modifying files Tracking new files Removing files Staging modified files Committing files Ignoring files
  • 9. Example of gitignore $ cat .gitignore *.[oa] *~ *.a # no .a files !lib.a # but do track lib.a, even though you're ignoring .a files above /TODO # only ignore the root TODO file, not subdir/TODO build/ # ignore all files in the build/ directory doc/*.txt # ignore doc/notes.txt, but not doc/server/arch.txt
  • 10. Viewing staged and unstaged changes git status git diff (Compares working directory with staging area) git diff --staged git diff HEAD git diff v1.0 v1.1 git diff master adposting
  • 11. Branching $ git add README test.rb LICENSE $ git commit -m 'initial commit of my project' Created on commit Created on add
  • 14. Creating new branch $ git branch testing
  • 16. Switching branch $ git checkout testing
  • 17. Significance of branch $ vim test.php $ git commit -am “made a change”
  • 18. Significance of branch $ git checkout master
  • 19. Significance of branch $ vim test.php $ git commit -am “made a change”
  • 20. Basic branching and merging • Create a new feature branch • Do some work in that branch Critical issue in production • Revert back to production branch • Create a new branch to add the hotfix • After testing, merge the hotfix branch and push to production • Switch back to your original issue and continue
  • 21. Basic branching and merging $ git checkout -b iss53 Switched to a new branch "iss53"
  • 22. Basic branching and merging $ vi index.html $ git commit -a -m 'added a new footer [issue 53]'
  • 23. Basic branching and merging Issue in production $ git checkout master Switched to branch “master” $ git checkout -b ‘hotfix’ Switched to a new branch “hotfix” $ vim index.html $ git commit -am ‘fixed a broken email address’ [hotfix]: created 3a0874c: "fixed the broken email address" 1 files changed, 0 insertions(+), 1 deletions(-)
  • 24. Basic branching and merging $ git checkout master $ git merge --no-ff hotfix Updating f42c576..3a0874c README | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) $ git branch -d hotfix Deleted branch hotfix (3a0874c).
  • 25. Basic branching and merging $ git checkout iss53 Switched to branch "iss53" $ vim index.html $ git commit -a -m 'finished the new footer [issue 53]' [iss53]: created ad82d7a: "finished the new footer [issue 53]" 1 files changed, 1 insertions(+), 0 deletions(-)
  • 26. Basic branching and merging $ git checkout master $ git merge iss53 Merge made by recursive. README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
  • 27. Basic branching and merging $ git branch -d iss53
  • 28. Branch management $ git branch # Shows all the active branches $ git branch -v # Shows last commit on each branch $ git branch --merged # Shows which branches are merged with the branch you are on $ git branch --no-merged # Shows all branches that contain work you haven’t merged $ git branch -d testing # To delete a branch. Will fail if the branch is not yet merged
  • 29. Remote branches • Remote branches are references to the state of branches on your remote repositories
  • 31. Remote branches $ git fetch origin # Fetches any data you don’t have from remote ‘origin’ repository $ git fetch origin master # Fetches data only from ‘master’ branch $ git pull origin # Fetches any data you don’t have and merges it with local branch $ git pull origin master # Fetches data from master and merges it with local master branch $ git push origin develop # Pushes data from local ‘develop’ branch to remote ‘develop’ branch $ git push origin develop:release # Pushes data from local ‘develop’ branch to remote ‘release’ branch git fetch origin
  • 32. Remotes $ git remote Origin $ git remote -v Origin ssh://clickindia@192.168.0.77/home/clickindia/public_html/clickindia $ git remote add test ssh://clickindia@test.clickindia.com/home/clickindia/public_html.... $ git remote rm origin
  • 35. How will we work? pull master master master pull develop push release Development Test server Production 192.168.0.77 Developer 1 Developer 2 Developer 3
  • 36. Tagging and release Once the code is merged into master production $ git tag -a v1.0.1 # applies v1.0.1 tag to current commit $ git tag # To list all tags $ git tag -1 ‘v1.4.2*‘ # List all tags starting with 1.4.2 $ git tag -a v1.0.1 -m ‘my version 1.0.1’ $ git show v1.4 tag v1.4 Tagger: Scott Chacon <schacon@gee-mail.com> Date: Mon Feb 9 14:45:11 2009 -0800 my version 1.4 commit 15027957951b64cf874c3557a0f3547bd83b3ff6 Merge: 4a447f7... a6b4c97... Author: Scott Chacon <schacon@gee-mail.com> Date: Sun Feb 8 19:02:46 2009 -0800 Merge branch 'experiment'
  • 37. Tagging Tagging later $ git log --pretty=oneline 15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch 'experiment' a6b4c97498bd301d84096da251c98a07c7723e65 beginning write support 0d52aaab4479697da7686c15f77a3d64d9165190 one more thing 6d52a271eda8725415634dd79daabbc4d9b6008e Merge branch 'experiment' 0b7434d86859cc7b8c3d5e1dddfed66ff742fcbc added a commit function 4682c3261057305bdd616e23b64b0857d832627b added a todo file 166ae0c4d3f420721acbb115cc33848dfcc2121a started write support 9fceb02d0ae598e95dc970b74767f19372d61af8 updated rakefile 964f16d36dfccde844893cac5b347e7b3d44abbc commit the todo 8a5cbc430f1a9c3d00faaeffd07798508422908a updated readme $ git tag -a v1.2 9fceb02
  • 39. Everyday commands Working on a new feature $ git pull origin develop $ git checkout -b adposting .....did development work..... $ git commit -am ‘Created new ad posting form’ $ git push origin adposting ......tested feature on development server..... $ git checkout develop $ git merge --no-ff adposting $ git push origin develop:release-v1.1.2 (push to test server as release-v1.1.2 .........fix testing bugs on release v1.1.2....... $ git fetch origin release-v1.1.2 ( on production only done by sysadmin ) $ git checkout master $ git merge --no-ff release-v.1.1.2 $ git tag -am v1.1.2 ‘released version v1.1.2’
  • 40. Everyday commands Working on a hotfix $ git pull origin master $ git checkout -b hotfixv1.1.1 master .....fixed bug on test server..... $ git commit -am ‘fixed e-mail address on contact page’ ....... Tested by deepak ........ $ git fetch origin hotfixv1.1.1 ( on production only done by sysadmin ) ...... Check if already on master....if not $ git checkout master $ git merge --no-ff hotfixv1.1.1 $ git tag -am v1.1.1 ‘released version v1.1.1’ $ git pull origin master ( on test and development servers)
  • 41. Version numbering v0.0.0 Major release Hot fixes Minor releases
  • 42. References • Progit.org -- a complete book on git • Gitref.org -- A very simple reference of all commands