mcgraths
1/5/2015 - 12:11 PM

Git Branching Commands

Git Branching Commands

Create a release branch:

git checkout -b release-1.2 develop
npm version [major | minor | patch | X.X.X]

Finishing a release branch :

git checkout master
git merge --no-ff release-1.2
git tag -a 1.2

git checkout develop
git merge --no-ff release-1.2

git branch -d release-1.2

Create a hotfix branch:

git checkout -b hotfix-1.2.1 master
npm version 1.2.1

Finishing a hotfix branch :

git checkout master
git merge --no-ff hotfix-1.2.1
git tag -a 1.2.1

git checkout develop
git merge --no-ff hotfix-1.2.1

git branch -d hotfix-1.2.1

Create a feature branch:

git checkout -b myfeature develop

Merge feature branch:

git checkout develop
git merge --no-ff myfeature
git branch -d myfeature
git push origin develop
  • Create a branch: git checkout -b [name_of_your_new_branch]
  • Download all remote branches: git fetch
  • List all branches: git branch -a
  • List all branches on remote: git branch -r
  • List all locally tracjed branches: git branch --list
  • Checkout a local copy of a remote branch: git checkout <branch_name>
  • Delete a local branch: git branch -d <branch_name>
  • Delete a remote branch: git push origin --delete <branch_name>
  • Sync remote deletes to local machine: git fetch --all --prune

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