Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

OS 4.2 (2 of 2): gitFlow and GitHub flow

The whole lesson, free. Read it and have a go at the activities. To work the tasks and labs in the real lesson, press Start lab, with no account needed.

50 minutes

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

Ten people, one file

Ten developers all change the same program on the same day. Nobody has rules.

Aisha fixes a bug. Ben adds a feature that is not finished. Sam deletes a file. The program stops working. Nobody knows whose change broke it.

A workflow gives the team rules so this does not happen.

Key words

WordWhat it means
RepositoryA store for code and its full history.
BranchA separate line of work. Changes on a branch do not touch the main code.
CommitA saved step in the history, with a message.
StageChoose which changes go into the next commit.
PushSend your commits from your computer to the server.
MergeJoin the changes from one branch into another.
Pull requestA request to merge your branch. Others can review it first.
Main branchThe branch that always holds the working, released code.
Feature branchA short branch made for one new feature.
ReleaseA version of the software given to users.
HotfixA quick fix for a serious bug in the released software.
WorkflowThe steps a team follows to get a change into the released code.

The cells students fill in are left blank in this preview.

GitHub flow keeps main ready

GitHub flow has one rule: the main branch is always ready to release.

To make a change, you make a short feature branch from main. You commit. You open a pull request. Others review it and tests run. Then you merge it into main and release.

It suits a team that releases often, such as a website.

Check: GitHub flow

Have a go

Check: GitHub flow

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

GitHub flow in one picture

gitGraph
  commit id: "start"
  branch add-login
  checkout add-login
  commit id: "login form"
  commit id: "login check"
  checkout main
  merge add-login id: "pull request merged"
  commit id: "release"

gitFlow adds a branch for each step

gitFlow has more branches and more rules.

The main branch holds only released versions. A develop branch holds the next version. Each feature has its own branch from develop. A release branch gets the next version ready. A hotfix branch fixes a bug in main at once.

It suits software with planned versions, such as a game or a banking app.

gitFlow in one picture

gitGraph
  commit id: "v1.0"
  branch develop
  checkout develop
  commit id: "start v1.1"
  branch feature-search
  checkout feature-search
  commit id: "search box"
  checkout develop
  merge feature-search
  branch release-1.1
  checkout release-1.1
  commit id: "last fixes"
  checkout main
  merge release-1.1 id: "v1.1"
  checkout develop
  merge release-1.1
  checkout main
  branch hotfix-1.1.1
  checkout hotfix-1.1.1
  commit id: "urgent fix"
  checkout main
  merge hotfix-1.1.1 id: "v1.1.1"
  checkout develop
  merge hotfix-1.1.1

Match the branch

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Which flow when?

GitHub flowgitFlow
Branches that stay for a long timeOne: mainTwo: main and develop
Other branchesShort feature branchesFeature, release and hotfix branches
ReleaseOften, straight from mainWhen a planned version is ready
Good forWebsites and small teamsProducts with versions to support
Weak atSeveral versions at onceSpeed: many steps for a small change

The cells students fill in are left blank in this preview.

Try GitHub flow in the lab

Press Start the lab and wait. The lab has a Git server called Gitea. Sign in at the Gitea tab as student with the password student.

The repository student/hello-git is already there. You make a feature branch and push it.

1. Get a copy

Command
git clone http://student:student@gitea:3000/student/hello-git.git

A command for the lesson’s lab terminal. It is shown here and not run.

2. Go into it

Command
cd hello-git

A command for the lesson’s lab terminal. It is shown here and not run.

3. Say who you are

Command
git config user.name "Student"

A command for the lesson’s lab terminal. It is shown here and not run.

3b. And your email

Command
git config user.email "[email protected]"

A command for the lesson’s lab terminal. It is shown here and not run.

4. Make a feature branch

Command
git checkout -b add-greeting

A command for the lesson’s lab terminal. It is shown here and not run.

5. Make a change

Command
echo "Hello from my branch" >> greeting.txt

A command for the lesson’s lab terminal. It is shown here and not run.

6. Stage the change

Command
git add greeting.txt

A command for the lesson’s lab terminal. It is shown here and not run.

7. Commit it

Command
git commit -m "Add a greeting"

A command for the lesson’s lab terminal. It is shown here and not run.

8. Push the branch

Command
git push -u origin add-greeting

A command for the lesson’s lab terminal. It is shown here and not run.

Open and merge a pull request

Open the Gitea tab. Open the repository student/hello-git. Gitea shows your new branch add-greeting. Press New Pull Request. Give it a clear title. Write a short description of the change. Create the pull request. Then press Merge Pull Request. Now go back to the terminal and run git checkout main, then git pull, to get the merged change. Write three lines: what branch you made, what the pull request said and what happened after the merge. Then answer: which flow did you just use, and why does it suit a small change?

A teacher marks this in a college. Nothing you write here is kept: it goes when you leave the page.

Make a free account to save your work, or press Start lab to work through the whole lesson.

Exit quiz

Have a go

Exit quiz

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teach this lesson with your class

On a college account your students work the tasks and the labs as well, and every mark is kept for you.