17
GIT Version Control davidx <[email protected] >

Git version control

Embed Size (px)

DESCRIPTION

GIT关于版本管理的一些操作, 没有基础的东西, 简单讲了一些命令, 大部分是概念的陈述

Citation preview

Page 2: Git version control

about branch

A branch in Git is simply a lightweight movable pointer to one of these commits.

“master” is the default branch

Page 3: Git version control

commandsgit branch

git checkout

git reset

git merge

git rebase

Page 4: Git version control

git branchgit branch - list all branches locally

git branch -r - list all branches on the remote side

git branch -d <XXX> - delete branch XXX

git branch -m <XXX> <YYY> - rename XXX to YYY

Page 5: Git version control

git checkout

git checkout <BRANCH NAME> - switch to that branch

git checkout -b <BRANCH NAME> - create a new branch and switch to that branch

Page 6: Git version control

git resetgit reset --hard HEAD - give up all uncommited changes

git reset --hard HEAD^ - back to the last commit

ATTENTION: these changes are permanent, you can not restore. Be careful.

Page 7: Git version control

git merge

git merge <BRANCH NAME> - merge changes to the current branch

Page 8: Git version control

git rebase

git rebase <BRANCH NAME> - get changes since master is changed

Page 9: Git version control

before rebase

A -> B -> C -- branch /D -> E -> F -- master

Page 10: Git version control

after rebase

A -> B -> C -- branch /D -> E -> F -- master

Page 11: Git version control

how we work

master branch is the root branch, you should not develop under this branch

all feature development should under their own branches

only when a feature is finished can it be merged into develop branch

bug fix should have its own branch

Page 12: Git version control

example

initiate a repository

create a new branch: develop

create a new feature branch:feature1

merge feature1 into develop

create a new feature branch:feature2

merge feature2 into develop

merge develop into master and create a tag for it

Page 13: Git version control

when you fix a bug

create a new branch from develop: 512

fix your bug

switch to develop

merge branch 512

delete branch 512 - this step is optional

Page 14: Git version control

work with svn

I don’t use any plugins for it

always update svn in master branch

always commit svn in master branch

develop or fix bug in new git branch

merge into master branch

rebase other branches if master get updates

Page 15: Git version control

git flow

it’s a very successful git branch model

it have 2 important branches: master, develop

develop is the hot branch, all tests can be done under this branch

Page 16: Git version control

Time

release branches masterdevelop hot!xesfeature

branches

Feature for future

release

Tag

1.0

Major feature for

next release

From this point on, “next release”

means the release after 1.0

Severe bug !xed for

production:hot!x 0.2

Bug!xes from rel. branch

may be continuously merged back into develop

Tag

0.1

Tag

0.2

Incorporate bug!x in develop

Only bug!xes!

Start of release

branch for1.0

Author: Vincent DriessenOriginal blog post: http://nvie.com/archives/323License: Creative Commons

Page 17: Git version control

Q & A