git introductive
DESCRIPTION
TRANSCRIPT
![Page 1: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/1.jpg)
Gitby Adham Saad
![Page 2: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/2.jpg)
Contents
• What is Version Control ?
• What is Git
• Installing Git
• Setup Git for the first time
![Page 3: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/3.jpg)
Contents
• Git Basicso Cloningo Stagingo Committingo Pushingo Reverting
• Git Branching
![Page 4: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/4.jpg)
Contents
• Git Stashing
• Submodules
• Resources
![Page 5: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/5.jpg)
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.
![Page 6: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/6.jpg)
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.
![Page 7: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/7.jpg)
What is Git
• This is how other Systems thinks of files
![Page 8: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/8.jpg)
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.
![Page 9: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/9.jpg)
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.
![Page 10: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/10.jpg)
Installing Git
• on Ubuntu$ apt-get install git
• For other OS
http://git-scm.com/book/en/Getting-Started-Installing-Git
![Page 11: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/11.jpg)
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.
![Page 12: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/12.jpg)
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/Add+an+SSH+key+to+an+account
)
![Page 13: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/13.jpg)
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
![Page 14: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/14.jpg)
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
![Page 15: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/15.jpg)
Adding Files
![Page 16: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/16.jpg)
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
![Page 17: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/17.jpg)
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)
![Page 18: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/18.jpg)
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
![Page 19: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/19.jpg)
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
![Page 20: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/20.jpg)
Stashing$ git stash
$ git pull
$ git stash pop
![Page 21: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/21.jpg)
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
![Page 22: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/22.jpg)
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 )
![Page 23: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/23.jpg)
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
![Page 24: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/24.jpg)
Resources
• http://wiki.zhibek.com/wiki/Training/Git (Please update this page if you found something interesting)
• http://git-scm.com/book
![Page 25: Git Introductive](https://reader033.vdocuments.us/reader033/viewer/2022061213/5497b518b47959794d8b530e/html5/thumbnails/25.jpg)
Questions