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...
What is Git
• The major difference between Git and any
other VCS (Subversion and friends included)
is the way Git thinks a...
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 snapsh...
What is Git
• To be efficient, if files have not changed, Git
doesn’t store the file again , just a link to the
previous i...
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 ( http...
Upload your Ssh key
• Go to
http://wiki.zhibek.com/wiki/Training/Git#SSH_key and
follow the steps to upload your ssh key t...
New Repository
• Create a new repository from here
https://bitbucket.org/repo/create
• Follow the steps introduced to you ...
Adding Files
• After cloning your repository , cd to it
• Add a new text file
$ git commit -m “your message”
• Here you ha...
Adding Files
Sharing
• Let’s share one repository with all of us
• One of us will make changes , commit and
push
• The others should se...
Branching
• Branching in git is not used to solve day to
day issues , but usually for introducing new
releases , or for wo...
Branching
• Create new branch
$ git checkout -b newbranch
• This is a shorthand for
$ git branch newbranch
$ git checkout ...
Stashing
• Sometimes , you didn't finish your task yet ,
but you want to pull the latest changes from
the server, and if y...
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...
Submodules
$ git submodule init
$ git submodule add
git@github.com:zendframework/zf2.git
library/zf2
• Note that you might...
Submodules
• You can clone a repo with its submodules by
running
$ git clone <repo_ssh_url> -- recursive
• or after clonin...
Resources
• http://wiki.zhibek.com/wiki/Training/Git (Please
update this page if you found something interesting)
• http:/...
Questions
Upcoming SlideShare
Loading in …5
×

Git Introductive

211 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
211
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Git Introductive

  1. 1. Git by Adham Saad
  2. 2. Contents • What is Version Control ? • What is Git • Installing Git • Setup Git for the first time
  3. 3. Contents • Git Basics o Cloning o Staging o Committing o Pushing o Reverting • Git Branching
  4. 4. Contents • Git Stashing • Submodules • Resources
  5. 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. 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. 7. What is Git • This is how other Systems thinks of files
  8. 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. 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. 10. Installing Git • on Ubuntu $ apt-get install git • For other OS http://git-scm.com/book/en/Getting-Started-Installing-Git
  11. 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. 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. 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. 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
  15. 15. Adding Files
  16. 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. 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. 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. 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. 20. Stashing $ git stash $ git pull $ git stash pop
  21. 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. 22. 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 )
  23. 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. 24. Resources • http://wiki.zhibek.com/wiki/Training/Git (Please update this page if you found something interesting) • http://git-scm.com/book
  25. 25. Questions

×