Upload
david-xie
View
631
Download
3
Tags:
Embed Size (px)
DESCRIPTION
GIT关于版本管理的一些操作, 没有基础的东西, 简单讲了一些命令, 大部分是概念的陈述
Citation preview
about branch
A branch in Git is simply a lightweight movable pointer to one of these commits.
“master” is the default branch
commandsgit branch
git checkout
git reset
git merge
git rebase
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
git checkout
git checkout <BRANCH NAME> - switch to that branch
git checkout -b <BRANCH NAME> - create a new branch and switch to that branch
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.
git merge
git merge <BRANCH NAME> - merge changes to the current branch
git rebase
git rebase <BRANCH NAME> - get changes since master is changed
before rebase
A -> B -> C -- branch /D -> E -> F -- master
after rebase
A -> B -> C -- branch /D -> E -> F -- master
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
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
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
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
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
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
Q & A