Skip to content

Instantly share code, notes, and snippets.

@tschmidt
Created April 3, 2012 21:38
Show Gist options
  • Save tschmidt/2295693 to your computer and use it in GitHub Desktop.
Save tschmidt/2295693 to your computer and use it in GitHub Desktop.
My Git Workflow (TL;DR version)
First Steps
========================================================================================
# Initialize git in a project
git init
# add and commit any existing files
git add .
git commit -m "Initial commit"
# associate with a remote repository
git remote add origin git@github.com/tschmidt/proposals.git
# push initial commit to remote
git push -u origin master
# create a new remote branch
git push origin master:refs/heads/develop
# create a local branch that is associated with a remote branch
git checkout -b develop --track origin/develop
Feature Branches
----------------------------------------------------------------------------------------
# make sure develop branch is up-to-date
git checkout develop
git pull
# create feature branch based on the develop branch
git checkout -b feature-some-descriptive-name develop
# test, hack, hack, hack
git add .
git commit -m "Description of change"
# test, hack, hack, hack
git add .
git commit -m "Description of change"
# merge the feature back into the develop branch and remove feature branch
git checkout develop
git merge --no-ff feature-some-descriptive-name
git branch -d feature-some-descriptive-name
Release Branches
----------------------------------------------------------------------------------------
# determine the next release number and create the branch. running `git tag' will
# show you the list of current tags
git checkout -b release-1.3 develop
# update the VERSION and HISTORY files. add and commit them.
git add .
git commit -m "Bumped version 1.3.0"
# merge into master
git checkout master
git merge --no-ff release-1.3
git push origin master
# tag the commit
git tag -a 1.3.0
git push --tags
# merge into develop
git checkout develop
git merge --no-ff release-1.3
git push origin develop
# remove the release branch
git branch -d release-1.3
Hotfix Branches
----------------------------------------------------------------------------------------
# create hotfix branch
git checkout -b hotfix-squash-bug-x master
# hack, hack, hack
git add .
git commit -m "Commit message"
# update VERSION and HISTORY files and commit changes
git add .
git commit -m "[HOTFIX] Explanation of hotfix"
# merge the hotfix back into master
git checkout master
git merge --no-ff hotfix-squash-bug-x
git push origin master
# tag the hotfix
git tag -a 1.3.1
git push --tags
# merge the hotfix into develop branch
git checkout develop
git merge --no-ff hotfix-squash-bug-x
# remove the hotfix branch
git branch -d hotfix-squash-bug-x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment