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
| Word | What it means |
|---|---|
| Repository | A store for code and its full history. |
| Branch | A separate line of work. Changes on a branch do not touch the main code. |
| Commit | A saved step in the history, with a message. |
| Stage | Choose which changes go into the next commit. |
| Push | Send your commits from your computer to the server. |
| Merge | Join the changes from one branch into another. |
| Pull request | A request to merge your branch. Others can review it first. |
| Main branch | The branch that always holds the working, released code. |
| Feature branch | A short branch made for one new feature. |
| Release | A version of the software given to users. |
| Hotfix | A quick fix for a serious bug in the released software. |
| Workflow | The 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 questionsGitHub 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 flow | gitFlow | |
|---|---|---|
| Branches that stay for a long time | One: main | Two: main and develop |
| Other branches | Short feature branches | Feature, release and hotfix branches |
| Release | Often, straight from main | When a planned version is ready |
| Good for | Websites and small teams | Products with versions to support |
| Weak at | Several versions at once | Speed: 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
git clone http://student:student@gitea:3000/student/hello-git.gitA command for the lesson’s lab terminal. It is shown here and not run.
2. Go into it
cd hello-gitA command for the lesson’s lab terminal. It is shown here and not run.
3. Say who you are
git config user.name "Student"A command for the lesson’s lab terminal. It is shown here and not run.
3b. And your email
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
git checkout -b add-greetingA command for the lesson’s lab terminal. It is shown here and not run.
5. Make a change
echo "Hello from my branch" >> greeting.txtA command for the lesson’s lab terminal. It is shown here and not run.
6. Stage the change
git add greeting.txtA command for the lesson’s lab terminal. It is shown here and not run.
7. Commit it
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
git push -u origin add-greetingA 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