You normally need to work on develop or feature branch
Create a new repository
mkdir myproject
cd myproject
git init
touch README.md
git add -A
git commit -m "First commit"
Create develop branch
git branch develop
Create new branch named develop
git branch
Show current branches
develop
* master
You are currently working with master branch
git checkout develop
You are currently working with develop branch
git push --all
Push new branch to remote repository
git push origin develop
First develop commit
git add -A
git commit -m "First commit"
git push
Create a release version from develop
When develop branch becomes stable, you need to merge develop modifications with master branch.
git checkout master
git pull
git merge --no-ff develop
merge develop modifications to master branch. The –no-ff options avoid fast forward commit method
git tag -a 1.0
add new tag called 1.0
git push --tags
push tags to the remote branch
git push
git checkout develop
Hotfix
The hotfix branch is used to fix bugs on master branch. Modifications needs to be merged into master and develop branches.
git checkout -b hotfix-1.0.1 master
Create a new branch and switch into.
Add your changes.
git add -A
git commit -m "Fixed some bugs"
git checkout master
git pull
git merge --no-ff hotfix-1.0.1
Merge with master
git tag -a 1.0.1
Add a tag
git checkout develop
git pull origin develop
git merge --no-ff hotfix-1.0.1
Merge with develop/em>
git branch -d hotfix-1.0.1
Delete hotfix branch
git push –tags
git push
Push tags and modifications
Create a feature branch
git checkout -b myfeature develop
git push origin myfeature
Write the code of the new feature
git checkout develop
git pull origin develop
git merge --no-ff myfeature
git push
git branch -d myfeature
git push origin :myfeature
Pull remote branch
git branch -a
Show all branches
git checkout -b develop origin/develop
Create a local branch from origin/develop
Links
http://nvie.com/posts/a-successful-git-branching-model/
http://book.git-scm.com/3_basic_branching_and_merging.html
http://help.github.com/git-cheat-sheets/
http://gitguru.com/2009/02/18/branching-strategies-overview/