Skip to main content
Foundations: web, servers, containersLesson 12 of 13

From Branch to Merge Request

Every CI/CD flow starts from one change (a commit) recorded in a Git repository. Follow how changes from two developers working at the same time go through review, get merged into the main line, and get a release version label.

Where A worksmain
Merge requestNone
main statusHealthy
Remote repo (GitLab, etc.)Developer ALogin pageDeveloper BEdits same pagefeat-loginA's branchmainMain linefeat-copyB's branchMRMerge requestAuto checksBuild · testReviewerFellow developerv1.4.2Tagclone
RequestResponse / reportAppears in a later step

What you will learn

  • Local vs remote repository
  • What one commit contains
  • What merge requests and code review do
  • Why conflicts happen and who resolves them
  • Git tags vs image tags

Terms and hands-on​

TermMeaning in one lineHow to check
Commit hashA unique string for each commitgit log --oneline shows the 7-character short hash and message
BranchA split-off line of workCreate with git switch -c feature/login, list with git branch
Merge requestA request to merge, plus the review recordGitLab calls it a merge request, GitHub a pull request. Preview the diff with git diff main
ConflictThe same line changed in different waysNot an error. Find conflicted files with git status, fix them by hand, then commit
TagA label on a commitAdd with git tag v1.2.0. Not the same as an image tag

If you put the commit hash or Git tag in the image tag, you can trace which code an image running in the cluster came from. See the running image in the Image field of kubectl describe deployment <name>.

Try it yourself​

git log --oneline --graph --all -n 20 # Commits, branches and merges
git branch -a # Local and remote branches
git show --stat HEAD # One commit: hash, author, message, files
git diff main...<branch> # What the merge request would show
git tag -n # Release tags

Check yourself

  1. B tries to merge and Git reports a conflict because A changed the same line differently. What does this mean?
  2. Why does A open a merge request instead of merging feat-login into main directly?
  3. You want to know which code a running image came from. What makes this easy?

Further reading: Pro Git · GitLab merge requests · GitHub pull requests