Git Version Control System

33
Distributed Source Version Control System Apr 2013

description

Git - Distributed Source Version Control System - The first public seminar of KMS Technology in 2013.

Transcript of Git Version Control System

Page 1: Git Version Control System

Distributed Source

Version Control System

Apr 2013

Page 3: Git Version Control System

Objectives

To use Git in software

project as doing with

SVN or TFS

To self study Git for

advanced needs

Confidential 3

Page 4: Git Version Control System

Syllabus

Git theory

Daily development workflow

Daily collaboration workflow

More on Git

Confidential 4

Page 5: Git Version Control System

Git’s history

Confidential 5

1999 2002

use patches and archived files

2005

use BitKeeper (a commercal system)

now

revoke BitKeeper, Linus Torvald

started developing Git

Source Version Control in Linux kernel project

Page 6: Git Version Control System

Syllabus

Git theory

Daily development workflow

Daily collaboration workflow

More on Git

Confidential 6

Page 7: Git Version Control System

Version Control Systems

Confidential 7

Centralized Version

Control Systems

Distributed Version

Control Systems

Page 8: Git Version Control System

Git theory

Data = Snapshot

No network

Three states

Confidential 8

Page 9: Git Version Control System

Git theory

Data = Snapshot

No network

Three states

Confidential 9

Page 10: Git Version Control System

Git theory

Data = Snapshot

No network

Three states

Confidential 10

git add

git rm

git status

Page 11: Git Version Control System

Syllabus

Git theory

Daily development workflow

Daily collaboration workflow

More on Git

Confidential 11

Page 12: Git Version Control System

Launch Git shell

Confidential 12

Page 13: Git Version Control System

Setup repository

Git in daily development

Confidential 13

git init

git clone

git add

git rm

git checkout

git commit

git status

git diff

git mv

git log

git checkout

git reset

Change repository Check repository

Undoing Update staging area

Page 14: Git Version Control System

Git remote url protocols

Local /data/git/project.git

SSH user@server:project.git

Git git://server/project.git

HTTP http://server/project.git

Confidential 14

Page 15: Git Version Control System

Remote repository

Confidential 15

Get remote repository

git remote add <url>

git clone git push

Get updates

git pull

git fetch

Page 16: Git Version Control System

Authenticate with remote

repository

1) Generate key files with ssh-keygen

2) Upload %USER_HOME%/.ssh/id_rsa.pub to

remote repository hosting

Read more: https://help.github.com/articles/generating-ssh-keys

Confidential 16

Page 17: Git Version Control System

Syllabus

Git theory

Daily development workflow

Daily collaboration workflow

More on Git

Confidential 17

Page 18: Git Version Control System

Branch (git branch)

Confidential 18

1

2 3

4

snapshot

git checkout master

Page 19: Git Version Control System

Merging - Fast forward

Confidential 19

git merge hotfix

Page 20: Git Version Control System

Merging - Non fast forward

Confidential 20

git merge iss53

(resolve conflicts if any)

Page 21: Git Version Control System

Remote branch workflows

Create default remote branch

Get changes from remote repository

Merge changes from remote branch in

local (two methods)

Update changes to remote repository

Confidential 21

Page 22: Git Version Control System

Create default remote branch

Confidential 22

Time

remote branch remote branch

Page 23: Git Version Control System

Get changes from remote

repository

Confidential 23

Time

git fetch origin

Page 24: Git Version Control System

Merge changes from remote

branch in local (v.1)

Confidential 24

Time

master origin/master

git merge origin/master

Page 25: Git Version Control System

Merge changes from remote

branch in local (v.2)

Confidential 25

Time

master origin/master

git pull origin

git fetch

+

git merge

Page 26: Git Version Control System

Update changes to remote

repository

Confidential 26

Time

master origin/master

master origin/master

git push origin/master

master

git.ourcompany.com

Page 27: Git Version Control System

Remote tracking branch

• Use tracking branch to let Git know which

server and branch to push / pull

• Create remote tracking branch:

Confidential 27

> git checkout -b [branch] [remote name]/[branch]

Page 28: Git Version Control System

Syllabus

Git theory

Daily development workflow

Daily collaboration workflow

More on Git

Confidential 28

Page 29: Git Version Control System

Useful features

> git tag

> git stash

> git submodule

Confidential 29

Page 30: Git Version Control System

Common problems

> git push

! [rejected] master -> master (non-fast forward)

Error: failed to push some refs to ‘git@gitproxy:rip747/cfwheels.git’

Confidential 30

> git pull

Merge made by recursive

> git push

To git@gitproxy:rip747/cfwheels.git

1717535..1406e8c master -> master

Page 31: Git Version Control System

Common problems (cont.)

• To remove remote branch e.g origin/iss105

• Use git tag to mark releases

Confidential 31

> git push origin :iss105

Page 32: Git Version Control System

Reference

For everything you want to read more about Git

http://git-scm.com

Confidential 32

Page 33: Git Version Control System

THANK YOU