Git Course 0%

A day in the life

Intermediate ≈ 15 min

What you will learn

  • The complete sequence for one change, in order
  • Which steps are your work and which are ritual
  • What the same day looks like on GitHub

After this lesson you can

  • I can take a piece of work from issue to merged without asking what comes next

Why this matters

You now know every command and every page. This lesson puts them in order, once, as a day actually goes. If you follow it for your first few changes, the sequence becomes automatic and you stop thinking about Git at all, which is the goal.

The whole day

A day in the life of one change Twelve steps in three rows. Morning: pick up the issue, update main with git pull, create a branch with git switch -c, and make the change. Middle of the day: run the checks locally, commit with a message naming the issue, push with git push -u origin, and open a merge request as a draft. Afternoon: the pipeline runs and review comments arrive, you push fixes, the reviewer approves and you merge with the source branch deleted, and finally you update your local main and delete the branch. Beside each step is the command or the place it happens. MORNING 1. Pick up the issue assign it to yourself read it twice 2. Start from current git switch main git pull 3. Branch git switch -c docs/12-windows-steps 4. Make the change one thing only in your editor MIDDAY 5. Check it yourself run the CI commands from the config file 6. Commit git add -p · git commit message names the issue 7. Push git push -u origin HEAD the link is in the output 8. Open it as a draft what · why · how to check Closes #12 AFTERNOON 9. Pipeline and review read the failing job answer every thread 10. Push fixes new commits, not amends then mark it ready 11. Approve and merge squash if that is the rule delete the source branch 12. Clean up update main and prune git branch -d <branch> Steps 9 and 10 repeat until the pipeline is green and the reviewer is happy; everything else happens once. Of the twelve, only steps 4 and 10 are your actual work. The rest is the same every time, which is why it becomes automatic. On GitHub the words change (pull request, checks) and the steps do not.
Twelve steps: pick up, update, branch, change, check, commit, push, open, review, fix, merge, clean up.

Morning

1. Pick up the issue

Assign it to yourself, so nobody duplicates the work, and read it twice. If anything is ambiguous, ask in the issue rather than in chat: the answer then lives where the next person will look (lesson 13.9).

2. Start from current main

Terminal
$ git switch main
$ git pull

Branching from a stale main is the most common cause of conflicts later (lesson 11.6).

3. Make the branch

Terminal
$ git switch -c docs/12-windows-install-steps

The issue number in the name is what links the branch, the commits and the merge request together (lesson 6.2). Many teams start the branch from the issue page instead, which names it for you.

4. Do the work

One thing at a time. If you notice something else that needs fixing, write it down as a new issue rather than adding it here: a merge request about two things takes twice as long to review and is twice as likely to be sent back.

Midday

5. Check it yourself

Read .gitlab-ci.yml or .github/workflows/*.yml and run what the pipeline runs:

Terminal
$ npx --yes markdownlint-cli "**/*.md" --ignore node_modules
$ python3 -m unittest discover -s tests -v

Ten seconds here saves a ten-minute round trip later (lesson 9.10).

6. Commit

Terminal
$ git status
$ git add docs/getting-started.md
$ git diff --staged
$ git commit -m "docs: add Windows steps to installation guide (#12)"

git diff --staged before every commit is the habit that catches the debugging line you left in.

7. Push

Terminal
$ git push -u origin docs/12-windows-install-steps

The output contains the link to open the merge request, which saves finding it in the interface.

8. Open it as a draft

Title, then a description with what, why, how to check and Closes #12. Add reviewers. Mark it a draft while you are still working (lesson 9.7).

Opening early is deliberate: the pipeline starts running, and a colleague can say "that is the wrong file" before you have spent the afternoon on it.

Afternoon

9. The pipeline and the review

The pipeline runs on every push. If it is red, open the failing job, read upwards from the end of the log, and fix what it names.

Review comments arrive as threads. Answer every one, even with "done" or "kept as is, because…" (lesson 9.8).

10. Push fixes

Terminal
$ git add docs/getting-started.md
$ git commit -m "docs: address review comments on the Windows steps"
$ git push

New commits, not amends: the reviewer needs to see what changed since they looked. The squash on merge tidies it up.

Then Mark as ready, and re-request review.

11. Approve and merge

When the pipeline is green and the approvals are in, merge with the option your team uses, ticking Delete source branch (lesson 13.4). The issue closes itself, because the description said Closes #12.

12. Clean up

Terminal
$ git switch main
$ git pull
$ git fetch --prune
$ git branch -d docs/12-windows-install-steps

Thirty seconds, and it keeps your branch list meaningful. Then pick up the next issue.

The same day on GitHub

Identical, with four words changed:

GitLab GitHub
Merge request Pull request
Pipeline Checks, run by Actions
Changes tab Files changed tab
Mark as ready Ready for review

The commands do not change at all (terminology map).

What the day is actually made of

Of the twelve steps, two are your work: step 4 and step 10. The other ten are the same every time, which is exactly why they are worth turning into a routine rather than a decision. Experienced people do not think faster about steps 2, 3, 7 and 12; they do not think about them at all.

How to do it

The whole day as commands, in order:

Terminal
$ git switch main && git pull
$ git switch -c docs/12-windows-install-steps
$ git status && git add <file> && git diff --staged
$ git commit -m "docs: … (#12)"
$ git push -u origin HEAD
$ git commit -am "docs: address review comments" && git push
$ git switch main && git pull && git fetch --prune
$ git branch -d docs/12-windows-install-steps

git push -u origin HEAD is worth knowing: HEAD means "the branch I am on", so the command is the same every time.

Common mistakes

  • Branching from a stale main, which produces avoidable conflicts.
  • Committing to main by habit (lesson 12.7).
  • Two unrelated changes in one merge request.
  • Waiting until the work is perfect to open the merge request. Open a draft early.
  • Not running the pipeline's own commands locally.
  • Leaving the branch behind after merging, so everyone's branch list grows.

Try it yourself

Goal: run the whole day once, deliberately.

  1. On your practice project, create an issue for a small documentation improvement.
  2. Follow all twelve steps above in order, without skipping the ones that feel unnecessary.
  3. Time yourself: note how long steps 4 and 10 take, and how long everything else takes.
  4. At the end, confirm: main up to date, branch gone locally and remotely, issue closed.
  5. Write down any step you had to look up. That is your list for next time.

Expected result: one merged change, a clean local repository, and a short list of the steps that are not yet automatic for you.

Show solution

Step 3 is the point of the exercise. The ratio is usually four or five to one in favour of the actual work, and the overhead shrinks with practice while the work does not. That is worth knowing when the process feels heavy on your first few changes.

Check yourself

1. Why start every change with git switch main && git pull?
2. Why open the merge request as a draft before the work is finished?
3. After merging, what are the three cleanup commands?

Key terms

Issue (ticket) Branch Merge request (MR) Pipeline Code review