Skip to content

Instantly share code, notes, and snippets.

@jbrodriguez
Last active April 28, 2019 08:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jbrodriguez/480fd9e474579d041860fc7ffb0eaaf2 to your computer and use it in GitHub Desktop.
Save jbrodriguez/480fd9e474579d041860fc7ffb0eaaf2 to your computer and use it in GitHub Desktop.
a git branching model (one branch / original + hybrid variant) WIP

oneflow

A flow based on this article

Comments from Adam on the original version of this gist can be found here

Original approach

Feature branches

# let's update master with the latest changes from the remote 
# to be safe, make sure you have no unpublished commits on the local master
git checkout master
git pull origin master

# Start work on a feature branch
git checkout -b feature/awesome

# implement awesome feature (feature 1, for example)

# commit changes
git add -A
git commit -m "add feature 1"

# ok i'm done with this feature branch, let's merge back to master
# first update master with latest changes from the remote
git checkout master
git pull --rebase origin master

# then merge the feature branch
git merge feature/awesome # deal with any merge conflicts here

# push to origin, remove branches
git push origin master
git branch -d feature/awesome
git push origin --delete feature/awesome

Release/Hotfix branches

# let's cut a release
git checkout master

# Start work on the release branch
git checkout -b release/1.0.0 <the-commit-you-want-your-release-on>

# bump versions, add changelog, etc

# commit changes 
git add -A
git commit -m "Release 1.0.0"

# tag the release and push it to the remote
git tag 1.0.0
git push --tags origin release/1.0.0

# now we merge back to master
# first update our master from the remote
git checkout master
git pull --rebase origin master

# then do the actual merge
git merge release/1.0.0 # deal with merge conflicts here

# push to origin, delete release branch
git push --tags origin master
git branch -d release/1.0.0
git push origin --delete release/1.0.0

Hybrid approach

Feature branches

# let's update master with the latest changes from the remote 
# to be safe, make sure you have no unpublished commits on the local master
git checkout master
git pull origin master

# Start work on a feature branch
git checkout -b feature/awesome

# implement awesome feature (feature 1, for example)

# commit changes
git add -A
git commit -m "add feature 1"

# ok i'm done with this feature branch
# let's update from master by rebasing
git fetch origin
git rebase -i origin/master # deal with conflicts here

git checkout master
git pull --rebase origin master

# then merge the feature branch
git merge --no-ff feature/awesome # no conflicts here

# push to origin, remove branches
git push origin master
git branch -d feature/awesome
git push origin --delete feature/awesome

Release/Hotfix branches

# let's cut a release
git checkout master <the-commit-you-want-your-release-on>

# Start work on the release branch
git checkout -b release/1.0.0

# bump versions, add changelog, etc

# commit changes 
git add -A
git commit -m "Release 1.0.0"

# tag the release and push it to the remote
git tag 1.0.0
git push --tags origin release/1.0.0

# now we merge back to master
# first update our master from the remote
git checkout master
git pull --rebase origin master

# then do the actual merge
git merge release/1.0.0 # deal with merge conflicts here

# push to origin, delete release branch
git push --tags origin master
git branch -d release/1.0.0
git push origin --delete release/1.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment