Module 4 · Git & GitHub: From First Commit to Pull Request
A Day on a Team: Putting It All Together
Practise the real workflow end to end. Handle an urgent bug while mid-task, resolve a conflict with a teammate's change, tag a release, and build the habits and checklists that make a Git user professional.
About 30 minutes
One day, many situations
You now know the pieces: commits, branches, merges, conflicts, undoing, remotes and pull requests. A real day on a team mixes them, and the work is rarely tidy. This lesson walks through a realistic day, and you practise each situation in the terminal.
The project is a small restaurant website. Your team is you and a teammate called Tunde.
9:00: Start the day
Always begin the same way: get the latest work.
Shell (bash)
git switch main
git pull
git switch -c feature/opening-hoursYou pull so you start from what the team has done. Then you make a branch for your task, never working directly on main. Describe the branch by the work: feature/opening-hours.
11:00: An urgent interruption
You are halfway through the opening-hours page, with files edited and not ready to commit. Your manager says there is a typo on the live menu that must be fixed now.
You cannot commit half-finished work, and Git will not let you switch branches if it would overwrite your changes. The answer is the stash (lesson 4):
Shell (bash)
git stash # put your half-done work in the drawer
git switch main # go to the stable branch
git switch -c fix/menu-typo # a branch for the urgent fix
# ...fix the typo...
git add menu.txt
git commit -m "Fix typo in the jollof rice name"
git switch main
git merge fix/menu-typo # (or a pull request on a team)
git switch feature/opening-hours
git stash pop # get your work backPractise this exact sequence in the first task below.
14:00: Tunde's change collides with yours
You finish the opening-hours page and merge main into your branch to check it still works, and Git says:
Output
CONFLICT (content): Merge conflict in hours.txtTunde also edited the Saturday hours. It is routine. You open the file, read the markers (lesson 6), decide together what is right (talk to Tunde!), edit the file, git add, and git commit. In the second task you do exactly this.
16:00: Release
When the work is merged into main and ready, teams mark the moment with a tag: a permanent, named label on a commit, usually a version number.
Shell (bash)
git tag v1.0
git tag # list tags
git push origin v1.0 # send the tag to GitHubTags make it easy to say "this is what we shipped on Friday", and to go back to it. On GitHub, you can turn a tag into a Release with notes for users. Version numbers like v1.2.3 usually mean: major changes that break things, minor new features, patch small fixes.
17:00: End of day habits
Before you close your laptop:
git status: is anything uncommitted that should not be lost?- Push your branch, even if the work is unfinished. It is a backup, and your team can see your progress.
- Update the issue or leave a note about where you stopped.
The professional's checklist
Print this and stick it beside your desk:
- Start with
git pullonmain, then branch. - Never work directly on
main. One branch per task. - Small commits, each one idea, each with a clear message.
git statusandgit diff --stagedbefore every commit.- Never commit secrets.
.gitignorefrom day one. - Pull before you push, and resolve conflicts calmly.
- Rewrite history only on private work. Use
reverton shared work. - Open small pull requests with a good description, and review others kindly.
- Delete merged branches, and tag releases.
- Ask for help early. Nobody remembers every command, and everybody searches for them.
Try it
First, the urgent interruption. You have half-finished work. Stash it, fix the urgent bug on its own branch, merge it, and come back.
Task
12 minYou are on feature/opening-hours with unfinished edits in hours.txt. A typo on the menu (Jolof) must be fixed now. Stash your work, fix the typo on a branch fix/menu-typo, merge it into main, return to your feature branch and restore your work.
Your repository is checked for
- You stashed your half-done work
- The urgent typo is fixed on main: main's menu says Jollof
- The fix was made on its own branch and merged into main
- You are back on your feature branch
- Your half-finished work is back (stash popped)
- The stash drawer is empty
- The fix commit message mentions the typo
Files in your project folder
Type a command below and press Enter. Type help for the commands you can use. Press the up arrow to bring back an earlier command.
Now the collision. Tunde changed the same line as you. Resolve it and finish the merge, keeping both pieces of information.
Task
10 minMerging opening-hours into main conflicted with Tunde's change in hours.txt. Resolve it by keeping both: Saturday 10 am to 6 pm, and the note that the restaurant is closed on Sundays. Finish the merge, and tag the release v1.0.
Your repository is checked for
- The branch opening-hours is merged into main
- No conflict markers are left
- The final hours.txt mentions Saturday 10 am
- It also keeps Tunde's note: closed on Sundays
- The merge is committed (clean)
- You tagged the release v1.0
Files in your project folder
Type a command below and press Enter. Type help for the commands you can use. Press the up arrow to bring back an earlier command.
Practice
You are mid-task with uncommitted changes and an urgent fix comes in. Which command puts your half-done work safely aside so you can switch branches? Type the full command.
Earn your badge
Take the module check
Questions on this module. Pass and you earn the GitHub Portfolio badge, free.
Create a free account to earn the badge