Reference

Gitflow cheat sheet

Every Gitflow command on one page: plain Git and the git-flow extension.

Setup

git switch -c develop main
Create develop from main
git push -u origin develop
Publish develop
git flow init -d
git-flow extension: initialise with defaults

Feature

git switch -c feature/x develop
Start a feature
git switch develop
Go back to develop…
git merge --no-ff feature/x
…and merge the feature
git branch -d feature/x
Delete the finished branch
git flow feature start x / finish x
Same, with git-flow

Release

git switch -c release/1.2.0 develop
Cut a release
git switch main && git merge --no-ff release/1.2.0
Ship it to main
git tag -a v1.2.0 -m "Release 1.2.0"
Tag the version
git switch develop && git merge --no-ff release/1.2.0
Merge fixes back
git push origin main develop --tags
Publish everything
git flow release start 1.2.0 / finish 1.2.0
Same, with git-flow

Hotfix

git switch -c hotfix/1.2.1 main
Branch from production
git switch main && git merge --no-ff hotfix/1.2.1
Ship the fix
git tag -a v1.2.1 -m "Hotfix 1.2.1"
Tag it
git switch develop && git merge --no-ff hotfix/1.2.1
Merge into develop (or the open release)
git flow hotfix start 1.2.1 / finish 1.2.1
Same, with git-flow

Everyday

git status
What changed?
git add -p
Stage changes hunk by hunk
git commit -m "msg"
Commit
git log --oneline --graph --all
See the branch graph
git fetch --prune
Update remote branches; drop deleted ones
git rebase develop
Update your feature branch
git push --force-with-lease
Safe force-push after a rebase
git restore <file>
Discard local edits
git revert <hash>
Undo a pushed commit safely
git reflog
Find "lost" commits