SlideShare a Scribd company logo
git 
KALANAMITH
VCS 
 Version control is a system that records changes to a file or set of 
files over time so that you can recall specific versions later.
Types of VCS 
 Local Version Control Systems 
 Centralized Version Control Systems 
 Distributed Version Control Systems
Local Version Control Systems 
File 
Version 3 
Version 2 
Version 1 
Checkout 
Local PC Version DB
Centralized Version Control Systems 
Computer A 
File 
Central VCS Server 
Version 3 
Version 2 
Version 1 
Checkout 
Version DB 
Computer B 
Checkout 
File
Distributed Version Control Systems 
Local Server / Cloud 
Version DB 
Version 3 
Version 2 
Version 1 
Local PC/ Another Cloud 
Version DB 
Version 3 
Version 2 
Version 1 
Local PC 
Version DB 
Version 3 
Version 2 
Version 1
git 
Linus Torvalds
Features 
 Speed 
 Simple design 
 Strong support for non-linear development (thousands of parallel 
branches) 
 Fully distributed 
 Able to handle large projects like the Linux kernel efficiently (speed 
and data size)
Getting Started 
 $ git config --global user.name <your_name> 
 $ git config --global user.email <your_email> 
 $ git config --global core.editor <your_editor> 
 $ git config --global merge.tool <your_merge_tool> 
 $ git config --list
Getting Started 
 $ git init 
 $ git add *.c 
 $ git add README 
 $ git commit -m 'initial project version'
Add your changes to remote 
 git init 
 git add readme.txt 
 git commit -m "first commit" 
 git remote add origin https://github.com/cazberra/mainrepo.git 
 git push -u origin master
Push an existing repositoty 
 git remote add origin https://github.com/cazberra/mainrepo.git 
 git push -u origin master
Cloning an Existing Repository 
 git clone [url] 
 git clone https://github.com/cazberra/mainrepo.git
git clone and git remote 
 They're basically the same, except clone will setup additional remote tracking 
branches 
 Git clone sets up a new repository similar to the one you are cloning 
 Adds the remote repository from which you cloned as the remote with the 
name origin 
 Just doing the last part of setting up a remote is "adding a remote repository" 
and doing the whole thing and getting a new clone is cloning. Note that when 
you add a remote repository, you already have a repository. When you clone, 
you do not already have the repository. 
 A repository can have multiple remotes added to it via git remote add. Usually 
these are remote repositories of the same repo's clones on peers and servers 
with which you push and pull.
 $ git remote –v 
 git remote add [shortname] [url] 
 $ git remote add pb git://github.com/paulboone/ticgit.git 
 $ git fetch [remote-name]
Tags 
 Git has the ability to tag specific points in history as being important. 
 To list available tags 
 $ git tag 
 Search for tags 
 git tag -l 'v1.4.2.*‘ 
 Create a Tag 
 $ git tag -a v1.4 -m 'my version 1.4' 
 Light weight tag 
 git tag v1.4-lw
Pushing Tags 
 $ git push origin v1.5 
 git push origin --tags
Branching 
 $ git branch <branch_name> 
 $ git checkout <branch_name> 
 Short Hand 
 $git checkout –b <branch_name> 
 Other useful commands 
 $ git branch –v 
 git branch –merged 
 git branch --no-merged
Branching Workflows
Merge 
 Check the branch you are working 
 $git branch 
 Checkout the branch you need to merge in to 
 $git checkout <master_or_the_branch_name> 
 $git merge <recently_worked_branch>
Remote Branches 
 $git push –u origin <remote_branch_name>
git file status
 $ git status 
 $ git add <file_name> 
 $git add –I 
 $git commit –m “Message” 
 $git commit –m “<task_id> <description>”
Do not do this! 
 $ git commit -a -m “not a best practice”
Removing Files 
 $ git rm <file_name> 
 Keep the file in your working tree but remove it from your staging 
area. In other words, you may want to keep the file on your hard 
drive but not have Git track it anymore. 
 $ git rm - -cached <file_name>
Viewing the Commit History 
 $ git log 
 -p, which shows the diff introduced in each commit. You can also 
use -2, which limits the output to only the last two entries 
 $ git log -p -2 
 $ git log --since=2.weeks 
 gitk
Undoing Things 
 $ git commit -m 'initial commit' 
 $ git add forgotten_file 
 $ git commit - -amend 
 $ git checkout <file_name>
How do you roll back (reset) a git 
repository to a particular commit? 
 git reset --hard <tag/branch/commit id> 
 git reset without the --hard option resets the commit history, but not 
the files. With the --hard option the files in working tree are also reset. 
 If you wish to commit that state, so remote repository also points to 
rolled back commit do: git push <reponame> -f 
 If nothing goes right try --force at the end of your git push command
Best Practices and Anti Patterns 
“bad practices in red” 
 GIT CHAMPIONS 
 Let Git Champions spread DVCS culture throughout your organization 
by starting with a small, experimental project, and eventually spreading 
to common code. 
 Try to bring everyone up to speed in one fell swoop. 
 CLI FIRST 
 Use the command line first — no tools 
 Use GUI and integrated tools first ‘to save time‘ (and learn nothing 
about DVCS)
 BLESSED REPOSITORY 
 Use Git with a shared but ‘blessed‘ repository 
 Allow developers to publish their repository in a many-to-many pull 
exchange fashion 
 CODE REVIEWS 
 Implement code reviews for distributed teams 
 Distributed development without code review
Self Study 
 Use git with Bitbucket 
 Use git with github 
 Use git with Open Shift 
 Use git with AppHarbour 
 ssh and git
Reference 
 http://git-scm.com/

More Related Content

PDF
git and github
PPTX
Git - Basic Crash Course
KEY
Introduction To Git
KEY
The everyday developer's guide to version control with Git
PPTX
Git and GitHub
PPTX
PDF
Git - An Introduction
PDF
Git and git flow
git and github
Git - Basic Crash Course
Introduction To Git
The everyday developer's guide to version control with Git
Git and GitHub
Git - An Introduction
Git and git flow

What's hot (20)

PDF
Git training v10
PDF
Git and github 101
PPTX
Git basics to advance with diagrams
PDF
Learning git
PDF
Git advanced
PPTX
Git 101 for Beginners
KEY
Introduction to Git
PDF
Advanced Git
PDF
Git flow Introduction
PDF
Git Series. Episode 3. Git Flow and Github-Flow
PPTX
Introduction git
PPTX
Source control
PPTX
Git & GitLab
PDF
Git-flow workflow and pull-requests
PDF
Git for beginners
KEY
Git and GitHub
PDF
Advanced Git Tutorial
PDF
Introduction To Git For Version Control Architecture And Common Commands Comp...
PPTX
Git One Day Training Notes
PPT
Introduction to Git
Git training v10
Git and github 101
Git basics to advance with diagrams
Learning git
Git advanced
Git 101 for Beginners
Introduction to Git
Advanced Git
Git flow Introduction
Git Series. Episode 3. Git Flow and Github-Flow
Introduction git
Source control
Git & GitLab
Git-flow workflow and pull-requests
Git for beginners
Git and GitHub
Advanced Git Tutorial
Introduction To Git For Version Control Architecture And Common Commands Comp...
Git One Day Training Notes
Introduction to Git
Ad

Viewers also liked (8)

PPTX
Icter cloud appfog_keynotes
PPTX
PPTX
PDF
HOW TO TRACK WHATSAPP MESSAGES OF OTHERS
PDF
Resume 2014 x3
PDF
Data model scorecard article 2 of 11
PDF
HOW TO TRACK WHATSAPP CHAT FREE
PPTX
business finance
Icter cloud appfog_keynotes
HOW TO TRACK WHATSAPP MESSAGES OF OTHERS
Resume 2014 x3
Data model scorecard article 2 of 11
HOW TO TRACK WHATSAPP CHAT FREE
business finance
Ad

Similar to Git (20)

PPTX
Introduction to Version Control
PPTX
Learning Basic GIT Cmd
ODP
Git tech talk
PPTX
Git presentation bixlabs
PPT
Git presentation
PPT
Git basic
PPTX
GIT.pptx
PDF
Collaborative development with Git | Workshop
PPTX
Mastering GIT
PPTX
Git Overview
PPTX
01 - Git vs SVN
PPTX
Git and Github
PPTX
Techoalien git
PPTX
Techoalien git
PPTX
Techoalien git
PPTX
Git and github
PDF
PDF
Git basics
PPTX
Git tutorial
Introduction to Version Control
Learning Basic GIT Cmd
Git tech talk
Git presentation bixlabs
Git presentation
Git basic
GIT.pptx
Collaborative development with Git | Workshop
Mastering GIT
Git Overview
01 - Git vs SVN
Git and Github
Techoalien git
Techoalien git
Techoalien git
Git and github
Git basics
Git tutorial

Recently uploaded (20)

PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Electronic commerce courselecture one. Pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Modernizing your data center with Dell and AMD
PDF
Encapsulation theory and applications.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation_ Review paper, used for researhc scholars
The Rise and Fall of 3GPP – Time for a Sabbatical?
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Approach and Philosophy of On baking technology
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Per capita expenditure prediction using model stacking based on satellite ima...
Review of recent advances in non-invasive hemoglobin estimation
Electronic commerce courselecture one. Pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Machine learning based COVID-19 study performance prediction
Modernizing your data center with Dell and AMD
Encapsulation theory and applications.pdf

Git

  • 2. VCS  Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.
  • 3. Types of VCS  Local Version Control Systems  Centralized Version Control Systems  Distributed Version Control Systems
  • 4. Local Version Control Systems File Version 3 Version 2 Version 1 Checkout Local PC Version DB
  • 5. Centralized Version Control Systems Computer A File Central VCS Server Version 3 Version 2 Version 1 Checkout Version DB Computer B Checkout File
  • 6. Distributed Version Control Systems Local Server / Cloud Version DB Version 3 Version 2 Version 1 Local PC/ Another Cloud Version DB Version 3 Version 2 Version 1 Local PC Version DB Version 3 Version 2 Version 1
  • 8. Features  Speed  Simple design  Strong support for non-linear development (thousands of parallel branches)  Fully distributed  Able to handle large projects like the Linux kernel efficiently (speed and data size)
  • 9. Getting Started  $ git config --global user.name <your_name>  $ git config --global user.email <your_email>  $ git config --global core.editor <your_editor>  $ git config --global merge.tool <your_merge_tool>  $ git config --list
  • 10. Getting Started  $ git init  $ git add *.c  $ git add README  $ git commit -m 'initial project version'
  • 11. Add your changes to remote  git init  git add readme.txt  git commit -m "first commit"  git remote add origin https://github.com/cazberra/mainrepo.git  git push -u origin master
  • 12. Push an existing repositoty  git remote add origin https://github.com/cazberra/mainrepo.git  git push -u origin master
  • 13. Cloning an Existing Repository  git clone [url]  git clone https://github.com/cazberra/mainrepo.git
  • 14. git clone and git remote  They're basically the same, except clone will setup additional remote tracking branches  Git clone sets up a new repository similar to the one you are cloning  Adds the remote repository from which you cloned as the remote with the name origin  Just doing the last part of setting up a remote is "adding a remote repository" and doing the whole thing and getting a new clone is cloning. Note that when you add a remote repository, you already have a repository. When you clone, you do not already have the repository.  A repository can have multiple remotes added to it via git remote add. Usually these are remote repositories of the same repo's clones on peers and servers with which you push and pull.
  • 15.  $ git remote –v  git remote add [shortname] [url]  $ git remote add pb git://github.com/paulboone/ticgit.git  $ git fetch [remote-name]
  • 16. Tags  Git has the ability to tag specific points in history as being important.  To list available tags  $ git tag  Search for tags  git tag -l 'v1.4.2.*‘  Create a Tag  $ git tag -a v1.4 -m 'my version 1.4'  Light weight tag  git tag v1.4-lw
  • 17. Pushing Tags  $ git push origin v1.5  git push origin --tags
  • 18. Branching  $ git branch <branch_name>  $ git checkout <branch_name>  Short Hand  $git checkout –b <branch_name>  Other useful commands  $ git branch –v  git branch –merged  git branch --no-merged
  • 20. Merge  Check the branch you are working  $git branch  Checkout the branch you need to merge in to  $git checkout <master_or_the_branch_name>  $git merge <recently_worked_branch>
  • 21. Remote Branches  $git push –u origin <remote_branch_name>
  • 23.  $ git status  $ git add <file_name>  $git add –I  $git commit –m “Message”  $git commit –m “<task_id> <description>”
  • 24. Do not do this!  $ git commit -a -m “not a best practice”
  • 25. Removing Files  $ git rm <file_name>  Keep the file in your working tree but remove it from your staging area. In other words, you may want to keep the file on your hard drive but not have Git track it anymore.  $ git rm - -cached <file_name>
  • 26. Viewing the Commit History  $ git log  -p, which shows the diff introduced in each commit. You can also use -2, which limits the output to only the last two entries  $ git log -p -2  $ git log --since=2.weeks  gitk
  • 27. Undoing Things  $ git commit -m 'initial commit'  $ git add forgotten_file  $ git commit - -amend  $ git checkout <file_name>
  • 28. How do you roll back (reset) a git repository to a particular commit?  git reset --hard <tag/branch/commit id>  git reset without the --hard option resets the commit history, but not the files. With the --hard option the files in working tree are also reset.  If you wish to commit that state, so remote repository also points to rolled back commit do: git push <reponame> -f  If nothing goes right try --force at the end of your git push command
  • 29. Best Practices and Anti Patterns “bad practices in red”  GIT CHAMPIONS  Let Git Champions spread DVCS culture throughout your organization by starting with a small, experimental project, and eventually spreading to common code.  Try to bring everyone up to speed in one fell swoop.  CLI FIRST  Use the command line first — no tools  Use GUI and integrated tools first ‘to save time‘ (and learn nothing about DVCS)
  • 30.  BLESSED REPOSITORY  Use Git with a shared but ‘blessed‘ repository  Allow developers to publish their repository in a many-to-many pull exchange fashion  CODE REVIEWS  Implement code reviews for distributed teams  Distributed development without code review
  • 31. Self Study  Use git with Bitbucket  Use git with github  Use git with Open Shift  Use git with AppHarbour  ssh and git