SlideShare a Scribd company logo
Git
by Adham Saad
Contents
• What is Version Control ?
• What is Git
• Installing Git
• Setup Git for the first time
Contents
• Git Basics
o Cloning
o Staging
o Committing
o Pushing
o Reverting
• Git Branching
Contents
• Git Stashing
• Submodules
• Resources
What is Version Control
• 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.
What is Git
• The major difference between Git and any
other VCS (Subversion and friends included)
is the way Git thinks about its data.
• Conceptually, most other systems store
information as a list of file-based changes.
What is Git
• This is how other Systems thinks of files
What is Git
• Git doesn’t think of or store its data this way.
• Instead, Git thinks of its data more like a set
of snapshots of a mini filesystem.
• Every time you commit, or save the state of
your project in Git, it basically takes a picture
of what all your files look like at that moment
and stores a reference to that snapshot.
What is Git
• To be efficient, if files have not changed, Git
doesn’t store the file again , just a link to the
previous identical file it has already stored.
Installing Git
• on Ubuntu
$ apt-get install git
• For other OS
http://git-scm.com/book/en/Getting-Started-Installing-Git
Setup Git for the first time
• There are several servers for git , in which
we can create our repositories
o Github ( https://github.com/ )
o Bitucket ( https://bitbucket.org/ )
o Assembla ( https://www.assembla.com )
• Let’s go to bitbucket and create an account
for free.
Upload your Ssh key
• Go to
http://wiki.zhibek.com/wiki/Training/Git#SSH_key and
follow the steps to upload your ssh key to
bitbucket (
https://confluence.atlassian.com/display/BITBUCKET/A
dd+an+SSH+key+to+an+account )
New Repository
• Create a new repository from here
https://bitbucket.org/repo/create
• Follow the steps introduced to you from the
website to use the repo for the first time
Adding Files
• After cloning your repository , cd to it
• Add a new text file
$ git commit -m “your message”
• Here you have added your files to the
staging state but not to the server
$ git push
• You have added your file to the server
Adding Files
Sharing
• Let’s share one repository with all of us
• One of us will make changes , commit and
push
• The others should see his changes after
running git pull
Branching
• Branching in git is not used to solve day to
day issues , but usually for introducing new
releases , or for working on something
different than the master branch (like design)
Branching
• Create new branch
$ git checkout -b newbranch
• This is a shorthand for
$ git branch newbranch
$ git checkout newbranch
• This is also how to switch to an existing branch.
$ git checkout master
Stashing
• Sometimes , you didn't finish your task yet ,
but you want to pull the latest changes from
the server, and if you do you might have
conflicts. Here comes git stash .
• The stash command is saving all your non
committed changes to something like a
stack, and the you can pop it again
Stashing
$ git stash
$ git pull
$ git stash pop
Submodules
• Git also provides an easy way to include
libraries called submodules
• Suppose you want to add zend framework 2
library in your project , it is simply by running
the following
Submodules
$ git submodule init
$ git submodule add
git@github.com:zendframework/zf2.git
library/zf2
• Note that you might need to add your ssh
key to github too )
Submodules
• You can clone a repo with its submodules by
running
$ git clone <repo_ssh_url> -- recursive
• or after cloning it you can run
$ git submodule init
$ git submodule update
Resources
• http://wiki.zhibek.com/wiki/Training/Git (Please
update this page if you found something interesting)
• http://git-scm.com/book
Questions
Ad

More Related Content

What's hot (20)

Git Introduction
Git IntroductionGit Introduction
Git Introduction
Anil Wadghule
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
Nilay Binjola
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
Mohammad Imam Hossain
 
Git basics
Git basicsGit basics
Git basics
Vijay Naik
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
Arulmurugan Rajaraman
 
Demo
DemoDemo
Demo
Miracle Anyanwu
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
Uri Goldstein
 
Git and GitHub crash course
Git and GitHub crash courseGit and GitHub crash course
Git and GitHub crash course
Mireia Sangalo
 
Git introduction workshop for scientists
Git introduction workshop for scientists Git introduction workshop for scientists
Git introduction workshop for scientists
Steven Hamblin
 
Git basics
Git basicsGit basics
Git basics
GHARSALLAH Mohamed
 
An Introduction to Git
An Introduction to GitAn Introduction to Git
An Introduction to Git
Hiroyuki Vincent Yamazaki
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
Safique Ahmed Faruque
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
Git 101
Git 101Git 101
Git 101
Sachet Mittal
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Somkiat Puisungnoen
 
Learning git
Learning gitLearning git
Learning git
Sid Anand
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
Pham Quy (Jack)
 
Git tutorial II
Git tutorial IIGit tutorial II
Git tutorial II
Jim Yeh
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
Behzad Altaf
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
Panagiotis Papadopoulos
 

Similar to Git Introductive (20)

Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
Kishor Kumar
 
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 hub
Git hubGit hub
Git hub
Nitin Goel
 
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
 
Bitbucket as a code server and pmt
Bitbucket as a code server and pmt Bitbucket as a code server and pmt
Bitbucket as a code server and pmt
malike4u
 
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
 
Mini git tutorial
Mini git tutorialMini git tutorial
Mini git tutorial
Cristian Lucchesi
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
Abdul Salam
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
Aditya Tiwari
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
Aditya Tiwari
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
Aditya Tiwari
 
Git 101
Git 101Git 101
Git 101
jayrparro
 
Git Training
Git TrainingGit Training
Git Training
Prabal Tyagi
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Nguyen Van Hung
 
Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHub
Kim Moir
 
Intro to Git for Drupal 7
Intro to Git for Drupal 7Intro to Git for Drupal 7
Intro to Git for Drupal 7
Chris Caple
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
PRIYATHAMDARISI
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
HubSpot
 
Git and GitHub Presentation of GDG on Campus UNSTPB
Git and GitHub Presentation of GDG on Campus UNSTPBGit and GitHub Presentation of GDG on Campus UNSTPB
Git and GitHub Presentation of GDG on Campus UNSTPB
AmaraCostachiu
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
tnscharishma
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
Kishor Kumar
 
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 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
 
Bitbucket as a code server and pmt
Bitbucket as a code server and pmt Bitbucket as a code server and pmt
Bitbucket as a code server and pmt
malike4u
 
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
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
Abdul Salam
 
Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHub
Kim Moir
 
Intro to Git for Drupal 7
Intro to Git for Drupal 7Intro to Git for Drupal 7
Intro to Git for Drupal 7
Chris Caple
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
PRIYATHAMDARISI
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
HubSpot
 
Git and GitHub Presentation of GDG on Campus UNSTPB
Git and GitHub Presentation of GDG on Campus UNSTPBGit and GitHub Presentation of GDG on Campus UNSTPB
Git and GitHub Presentation of GDG on Campus UNSTPB
AmaraCostachiu
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
tnscharishma
 
Ad

Git Introductive

  • 2. Contents • What is Version Control ? • What is Git • Installing Git • Setup Git for the first time
  • 3. Contents • Git Basics o Cloning o Staging o Committing o Pushing o Reverting • Git Branching
  • 4. Contents • Git Stashing • Submodules • Resources
  • 5. What is Version Control • 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.
  • 6. What is Git • The major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data. • Conceptually, most other systems store information as a list of file-based changes.
  • 7. What is Git • This is how other Systems thinks of files
  • 8. What is Git • Git doesn’t think of or store its data this way. • Instead, Git thinks of its data more like a set of snapshots of a mini filesystem. • Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.
  • 9. What is Git • To be efficient, if files have not changed, Git doesn’t store the file again , just a link to the previous identical file it has already stored.
  • 10. Installing Git • on Ubuntu $ apt-get install git • For other OS http://git-scm.com/book/en/Getting-Started-Installing-Git
  • 11. Setup Git for the first time • There are several servers for git , in which we can create our repositories o Github ( https://github.com/ ) o Bitucket ( https://bitbucket.org/ ) o Assembla ( https://www.assembla.com ) • Let’s go to bitbucket and create an account for free.
  • 12. Upload your Ssh key • Go to http://wiki.zhibek.com/wiki/Training/Git#SSH_key and follow the steps to upload your ssh key to bitbucket ( https://confluence.atlassian.com/display/BITBUCKET/A dd+an+SSH+key+to+an+account )
  • 13. New Repository • Create a new repository from here https://bitbucket.org/repo/create • Follow the steps introduced to you from the website to use the repo for the first time
  • 14. Adding Files • After cloning your repository , cd to it • Add a new text file $ git commit -m “your message” • Here you have added your files to the staging state but not to the server $ git push • You have added your file to the server
  • 16. Sharing • Let’s share one repository with all of us • One of us will make changes , commit and push • The others should see his changes after running git pull
  • 17. Branching • Branching in git is not used to solve day to day issues , but usually for introducing new releases , or for working on something different than the master branch (like design)
  • 18. Branching • Create new branch $ git checkout -b newbranch • This is a shorthand for $ git branch newbranch $ git checkout newbranch • This is also how to switch to an existing branch. $ git checkout master
  • 19. Stashing • Sometimes , you didn't finish your task yet , but you want to pull the latest changes from the server, and if you do you might have conflicts. Here comes git stash . • The stash command is saving all your non committed changes to something like a stack, and the you can pop it again
  • 20. Stashing $ git stash $ git pull $ git stash pop
  • 21. Submodules • Git also provides an easy way to include libraries called submodules • Suppose you want to add zend framework 2 library in your project , it is simply by running the following
  • 22. Submodules $ git submodule init $ git submodule add [email protected]:zendframework/zf2.git library/zf2 • Note that you might need to add your ssh key to github too )
  • 23. Submodules • You can clone a repo with its submodules by running $ git clone <repo_ssh_url> -- recursive • or after cloning it you can run $ git submodule init $ git submodule update
  • 24. Resources • http://wiki.zhibek.com/wiki/Training/Git (Please update this page if you found something interesting) • http://git-scm.com/book