Git Workflows

How teams organise branches, reviews and releases. Each workflow below comes with its rules as stated by its original source, when it fits, and an animated walkthrough — run by the Git simulator and verified against real Git.

WorkflowLong-lived branchesHow it releasesFits best
mainDeploy main after every merged pull requestContinuously deployed apps
main, developRelease branches, tagged on mainVersioned software, several versions supported
main (the trunk)From the trunk, or a short-lived release branchCI/CD teams integrating daily
upstream’s mainMaintainers merge pull requests from forksOpen source, contributors without write access

GitHub flow

One main branch + short-lived branches + pull requests

A lightweight, branch-based workflow. Everything in main is deployable; each change is made on its own descriptively named branch and merged into main through a reviewed pull request, then deployed.

The rules

  1. Anything in the main branch is deployable.
  2. Create a descriptively named branch off main for each change.
  3. Commit locally and push regularly to the branch of the same name.
  4. Open a pull request for feedback, or when the branch is ready to merge.
  5. Merge into main after review, then delete the branch.
  6. Deploy as soon as it is merged (in the original post: “you can and should deploy immediately”).

✓ Use it when

Web apps and services that deploy continuously from a single version.

✗ Avoid it when

You must maintain several released versions in parallel.

Sources

Opening and merging the pull request happen on GitHub; the walkthrough shows the equivalent Git operations (GitHub’s default merge button creates a merge commit).

Start the workflow and walk through it once.

YOUR FILES — ONE FILE, THREE PLACESWorking diryour diskStagingnext commitHEADlast commitadd ›commit ›GITUALIZE☁ ORIGIN — github.com/acme/shop (another repository)YOUR REPOSITORY — .git on your laptop2e039acAdd homepage2e039ac897849007af489a58ee9eec107a21974e Add homepageb272b3aSet up projectb272b3abaca08f2f1c56c0562679f66a61035535 Set up project129c2dbInitial commit129c2db06bfe68f8469dc82e6e05d1c03d1f768c Initial commit2e039acAdd homepage2e039ac897849007af489a58ee9eec107a21974e Add homepageb272b3aSet up projectb272b3abaca08f2f1c56c0562679f66a61035535 Set up project129c2dbInitial commit129c2db06bfe68f8469dc82e6e05d1c03d1f768c Initial commitmainmain: a movable label on a commitorigin/mainorigin/main: your LOCAL bookmark of where origin's branch was at your last fetch/pushHEADHEAD → the branch you are onmainmain: as it exists ON originREADME.mdunchangedapp.jsunchangedindex.htmlunchangedv1v1v1v1v1v1v2v2v2HEAD → main → 2e039ac “Add homepage”
0.0s / 142s
commitring = the commit HEAD is onunreachable (still exists)branch = movable labelorigin/* = your bookmark of the remoteHEAD = where you are
  1. 1 Create a branch

  2. 2 Make changes

  3. 3 Create a pull request

  4. 4 Address review comments

  5. 5 Merge your pull request

  6. 6 Delete your branch