Date post: | 13-Jul-2015 |
Category: |
Technology |
Upload: | raiful-hasan |
View: | 322 times |
Download: | 0 times |
Objective
• Understand the advantage of GIT and determine if we should use GIT or not.
12/12/201
2
2
Know how to use the common used GIT commands
Subject
Characteristic of GIT
– The most powerful features of GIT
– Explain the differences between GIT and SVN
• GIT basic usages
- Day to day GIT used commands
• Resources
12/12/2012 3
History
Invented by Linus Torvalds to support the development of the Linux Kernel
Incredibly fast, very efficient with large projects, has an incredible branching system
for non-linear development
• Projects using Git : Linux Kernel, Perl, Eclipse, Android ...
12/12/2012 5
Compare to SVN
There are many version control tools in the market But GIT is a completely difference
tool GIT own many distinct, powerful features
• Interface is fairly similar to SVN
• Git stores and thinks about data differently than SVN
12/12/2012 6
Compare to SVN(cont..)
SVN Data Model:
SVN store history as a list of file-based
changes
12/12/2012 7
GIT Data Model:Database addressable by the hash value of its
contents
Compare to SVN(cont..)
Repository
GIT - Local and multi Remote Repositories
SVN – only 1 repository on server
• SVN may loose history in some case, Git doesn't
12/12/2012 8
Compare to SVN(cont..)
5 Fundamental differences between GIT & SVN
1. GIT is distributed, SVN is not
2. GIT stores content as metadata, SVN stores just files
3. GIT branches are much more easier & fun is not the same as SVN branches.
4. GIT does not have a global revision no. like SVN do
5. GIT’s content integrity (using SHA-1 hash algorithm) is better than SVN’s.
12/12/2012 9
Why's GIT fast ?
• The internal database structure
Nearly every operation is Local. Entire history is on local disk
This database is compressed effectively transfer over network, use SSH or GIT
protocol
12/12/2012 10
State
• States : untracked, modified, and staged, committed
12/12/2012 11
Untracked Unmodified Modified Staged
Edit the File
Add the FileStage the File
Remove the File
Commit
File Status Lifestyle
Working Area
• The Git directory, the working directory, and the staging area.
12/12/2012 12
Working
DirectoryStaging Area
Git Directory
(repository)
Checkout the Project
Stage Files
Commit
Local Operation
Branch Management
Killer feature – Managing branches. Make Git apart in the VCS community
Branching operations nearly instantaneous. Switching back and forth between
branches just as fast
We can create branches, and merge often even multiple times in a day
12/12/2012 13
Switch Branch
12/12/2012 14
98ca9 34ac2 f30ab
master
testing
HEADSwitch Branch
98ca9 34ac2 f30ab
master
testing
HEADPoint to Current Branch
FastForward Merge
12/12/2012 15
98ca9 34ac2 f30ab
master
testing
HEAD
c2b9e
98ca9 34ac2 f30ab
master
testing
HEAD
c2b9e
Move Pointer Forward
FastForward Push
GIT “push” comand equals to svn commit. By default, GIT only allow “FastForward”
push. To override this, use --force option
12/12/2012 16
before push
public repository's master
after force push
C0 C1 C2
C3
master
C4
12/12/2012 23
Merge vs. Rebase
C1
C2
C3
C4
C5
C6
Merge
Master Idea
C1
C2
C3
C4
C5
C6
Rebase
Master Idea
12/12/2012 24
Merge vs. Rebase
C1
C2
C3
C4
C5
C6
Rebase
Master Idea
C1
C2
C3
C4
C7
C5
C6
Merge Commit
Master
Idea
Merge
12/12/2012 25
C1
C2
C3
C4
C7
C5
C6
Merge
Merge Commit
Master
Idea
C1
C2
C3
C4
C5
C6
Rebase
IdeaMaster
C3’
1
2
1
2
Merge vs. Rebase
C4’
Merge vs. Rebase
12/12/2012 26
C1
C2
C3
C4
C7
C5
C6
Merge
Merge Commit
Master
Idea
C1
C2
C5
C6
C3
C4
Rebase
Idea
Master
C3’
C4’
12/12/2012 29
git clone [email protected]:project.git
Computer A
Computer B
Divine Server
C1 C2
Master
C1 C2
Master
Origin/Master
Push Pull
12/12/2012 30
git clone [email protected]:project.git
Computer A
Computer B
Divine Server
C1 C2
Master
C1 C2
Master
Origin/Master
C1 C2
Master
Origin/Master
Push Pull
12/12/2012 31
git commit -a -m “ComputerA's new feature"
Computer A
Computer B
Divine Server
C1 C2
Master
C1 C2
Master
Origin/Master
C1 C2
Master
Origin/Master
a1 a2
Push Pull
12/12/2012 32
git commit -a -m “ComputerB's new feature"
Computer A
Computer B
Divine Server
C1 C2
Master
C1 C2
Master
Origin/Master
C1 C2
Origin/Master
a1 a2
Master
b1 b2
Push Pull
12/12/2012 33
git push origin master
Computer A
Computer B
Divine Server
C1 C2
Master
C1 C2
Master
Origin/Master
C1 C2
Origin/Master
a1 a2
Master
b1 b2
Push Pull
12/12/2012 34
git push origin master
Computer A
Computer B
Divine Server
C1 C2
Master
C1 C2
Master
Origin/Master
C1 C2
Origin/Master
a1 a2
Master
b1 b2
b1 b2
Push Pull
12/12/2012 35
git push origin master
Divine Server
C1 C2
Master
C1 C2
Master
Origin/Master
C1 C2
Origin/Master
a1 a2
Master
b1 b2
b1 b2
Push Pull
12/12/2012 36
git fetch
Divine Server
C1 C2
Master
C1 C2
Master
Origin/Master
C1 C2
Origin/Master
a1 a2
Master
b1 b2
b1 b2
b1 b2
Push Pull
12/12/2012 37
git merge origin/master
Divine Server
C1 C2
Master
C1 C2
Master
Origin/Master
C1 C2
Origin/Master
a1 a2
Master
b1 b2
b1 b2
b1 b2
a3
Push Pull
12/12/2012 38
git push origin master
Divine Server
C1 C2
Master
C1 C2
Master
Origin/Master
C1 C2
Origin/Master
a1 a2
Master
b1 b2
b1 b2
b1 b2
a3
a1 a2 a3
Push Pull
Installing GIT
• Address: http://git-scm.com/download
• Window, Mac – Download Installation file
Linux - The primary Git package :
git-core, git-doc – document
git-cvs, git-svn – work with CVS, or SVN
gitk – graphical application
• $ sudo apt-get install git-core git-doc gitk git-svn
12/12/2012 40
Resources
More explanation why use GIT
http://whygitisbetterthanx.com
Basic tutorial
Version Control with Git - O'Reilly Media “Advance GIT”
12/12/2012 41