Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Created October 7, 2022 08:31
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ocramius/a34f2d2026d3e09cf2c3a4e865787028 to your computer and use it in GitHub Desktop.
Save Ocramius/a34f2d2026d3e09cf2c3a4e865787028 to your computer and use it in GitHub Desktop.
A healthy git-flow (if you can call git-flow healthy at all), in which `master` is correctly merged back to `develop`
git checkout -b master
git log -1
# commit 65345471c1040ceb90b1817d7427d58d7b09fdca (HEAD -> master)
git checkout -b develop
git log -1
# both branches are at the same ref:
# commit 65345471c1040ceb90b1817d7427d58d7b09fdca (HEAD -> develop, master)
echo "a feature" > feature.txt
git add feature.txt
git commit -m "Added a feature"
git log -1
# `develop` moved away: this is normal, as we add features
# commit 5d0a89cce32cef9fa8124c91143e8d7023bb0019 (HEAD -> develop)
git checkout master
echo "a hotfix" > hotfix.txt
git add hotfix.txt
git commit -m "Applied critical hotfix"
git log -1
# `master` also moved due to a hotfix: we now need to merge it back to develop
# commit 1868717778d46493707571db51a0caf468545696 (HEAD -> master)
git checkout develop
git merge --no-ff master -m "Merging master back into develop"
git log -1
# `develop` is still ahead of `master`: this is still normal, since more commits are in `develop`
# commit 7fcfa36c5de19b40f1c50aad848b1514729989b9 (HEAD -> develop)
# we bring them together when we do a feature develop:
git checkout master
git merge --no-ff develop -m "Release 2022-09-14"
git log -1
# `master` contains a merge commit that is not in `develop`, but we can fast-forward `develop` now!
# commit 7458cc20a8c8128fac214c705ce85d8764f9f11e (HEAD -> master)
git checkout develop
git merge --ff-only master
# Updating 7fcfa36c5d..7458cc20a8
# Fast-forward
git log -1
# and here we have it: `develop` and `master` at the same state, when we do a develop
# commit 7458cc20a8c8128fac214c705ce85d8764f9f11e (HEAD -> develop, master)
@Ocramius
Copy link
Author

Ocramius commented Oct 7, 2022

Related: my critique to git-flow (and why github-flow makes more sense) at https://gist.github.com/Ocramius/bc5c76313ddfea340e3dcc31c991a682

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment