YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: Git and git flow

Git flow & Git

Page 2: Git and git flow

Init a project with existing files

git flow init

Creates two branches:master (production release)develop (next release)

Supported branches prefixes:featurereleasehotfix

Page 3: Git and git flow

After finishing "my-hotfix", master and develop have the commits made in the hotfix branch

Hotfixes workflow

Command master my-hotfix develop

git flow hotfix start my-hotfix

working in hotfix

git commit -am "msg"

git flow hotfix finish my-hotfix

Page 4: Git and git flow

git flow hotfix start my-hotfix

is equivalent to the next git commands

git checkout mastergit branch hotfix/my-hotfixgit checkout hotfix/my-hotfix

or

git checkout -b hotfix/my-hotfix master

Starting a hotfix

Page 5: Git and git flow

git flow hotfix finish my-hotfix

is equivalent to the next git commandsgit checkout mastergit merge --no-ff hotfix/my-hotfixgit checkout developgit merge --no-ff hotfix/my-hotfixgit branch -d hotfix/my-hotfix

don't forget to push master and develop into origingit push origin [master|develop]

Finishing a hotfix

Page 6: Git and git flow

After finishing "my-feature", only develop has the commits made in the feature branch

Features workflow

Command master my-feature develop

git flow feature start my-feature

working in feature

git commit -am "msg"

git flow feature finish my-feature

Page 7: Git and git flow

git flow feature start my-feature

is equivalent to the next git commands

git checkout developgit branch feature/my-featuregit checkout feature/my-feature

or

git checkout -b feature/my-feature develop

Starting a feature

Page 8: Git and git flow

git flow feature finish my-feature

is equivalent to the next git commands

git checkout developgit merge --no-ff feature/my-featuregit branch -d feature/my-feature

don't forget to push develop into origingit push origin develop

Finishing a feature

Page 9: Git and git flow

After finishing "v2.0", master and develop have the commits made in the release branch

Releases workflow

Command master v2.0 develop

git flow release start v2.0

working in release

git commit -am "msg"

git flow feature finish v2.0

Page 10: Git and git flow

git flow release start my-release

is equivalent to the next git commands

git checkout developgit branch release/my-releasegit checkout release/my-release

or

git checkout -b release/my-release develop

Starting a release

Page 11: Git and git flow

git flow release finish my-release

is equivalent to the next git commandsgit checkout mastergit merge --no-ff release/my-releasegit tag -a my-releasegit checkout developgit merge --no-ff release/my-releasegit branch -d release/my-release

don't forget to push master and develop into origingit push origin [master|develop]

Finishing a release

Page 12: Git and git flow

Hotfixesgit checkout mastergit pullgit checkout hotfix-branch git merge master

Featuresgit checkout developgit pullgit checkout feature-branchgit merge develop

What if my branch gets obsolete?

Page 13: Git and git flow

git flow [hotfix|feature|release] publish my-branch

you can checkout remote branches like this

git checkout -b my-branch origin/my-branch

don't forget to remove them when they are not needed anymore

git push origin :my-branch

Publishing remote branches

Page 14: Git and git flow

Suitable to support old versions of the software but in a very EXPERIMENTAL status and NOT RECOMENDABLE for production environments

git flow support start v1.1.1 v1.0

Support branches

Page 15: Git and git flow

Useful git commands

Page 16: Git and git flow

Log of the last 2 commitsgit log -2

Differences in the last 2 commitsgit log -2 -p

Differences between commitsgit diff 77cf297..eb0df61gif diff --name-only 77cf297..eb0df61fgit diff HEAD..HEAD^1 filename

Showing the last commits

Page 17: Git and git flow

Useful when we need to checkout another branch and we don't still want to commit anything

git stashgit stash listgit stash popgit stash apply stash@{0}git stash show stash@{1}git stash drop stash@{0}

Saving work without committing

Page 18: Git and git flow

If the file hasn't been added to the indexgit checkout one.txt

If the file has already been added to the indexgit reset HEAD one.txt

If we want to undo a commit but keeping the modificationsgit reset --soft sha1_commit

If we want to undo a commit completelygit reset --hard sha1_commit

Throwing changes away

Page 19: Git and git flow

Fixing mistakes with git

Page 20: Git and git flow

Committing too early

git commit -m "my message"

I forgot to add the file one.txt and I don't want to do another commit

git add one.txtgit commit --amend

Page 21: Git and git flow

Committing too early again

git add two.txt three.txtgit commit -m "my message"

I don't want the file three.txt in this commit

git reset HEAD^1 three.txtgit commit --amend

Page 22: Git and git flow

Fixing mistakes in previous commits

An error in the file four.txt was introduced in a previous commit

git checkout <SHA1_commit>vim four.txtgit add four.txtgit commit --amendgit rebase --onto HEAD <SHA1_commit> <branch>

Page 23: Git and git flow

Recovering local deleted branch

git branch -D my-feature

Looking for the last commit in the deleted branch and getting its SHA1 with git reflog

git branch my-feature <sha1_last_commit>

Page 24: Git and git flow

Links

● http://git-scm.com/documentation

● http://nvie.com/posts/a-successful-git-branching-model/


Related Documents