Lesson 1 Β· Foundations

🌿 Version Control & Git Workflows

DevOps starts with the thing every change passes through: version control. A team's whole release process is built on top of a shared, reliable history of who changed what, and why.

🌿 Commits, branches and history

A commit is a saved snapshot with a message explaining the change. A branch is a separate line of commits, usually used for one feature or fix, so work in progress never disturbs the stable main branch.

git switch -c feature/login # create and switch to a new branch git add . git commit -m "Add login form validation" git push -u origin feature/login # push the branch to the shared repo

A good commit message explains why, not just what the diff already shows.

🖼️ See it

A typical feature branch workflow🌿Branch frommainπŸ“CommitchangesπŸ”Push & openPRβœ…Review &checks passπŸ”€Merge tomain

🖼️ See it

Merge vs rebaseMergeKeeps full, true historyAdds a merge commitSafe on shared branchesRebaseProduces a clean, linear historyRewrites commit historyOnly on your own unshared branch

πŸ”€ Merging vs rebasing

Merge combines two branches and adds a merge commit, keeping the exact history of both. Rebase replays one branch's commits on top of another, producing a straight, cleaner line β€” but it rewrites commit history, which is risky on a branch others are also using.

git merge feature/login # keeps both histories, adds a merge commit git rebase main # replays feature/login's commits onto latest main
Rule of thumb. Rebase your own, not-yet-shared branch to tidy it up; merge (never rebase) a branch other people have already pulled.

πŸ” Pull requests and code review

A pull request (PR) proposes merging one branch into another and is where teammates review the diff, leave comments, and require checks (tests, linting) to pass before it can merge.

.gitignore lists files Git should never track β€” build output, dependencies, local secrets (.env) β€” keeping the repository focused on source code only.

Common mistake. Committing a real .env file or an API key straight into history. Once pushed, treat the secret as compromised and rotate it β€” deleting the file afterwards does not remove it from history.

πŸͺœ Step by step: fixing a merge conflict

Read both versions, decide the correct result, remove the markers, test and commit.

Problem: Merging feature into main, a file shows: <<<<<<< main timeout = 30 ======= timeout = 60 >>>>>>> feature Resolve it.

  1. Understand both sides.
    main: 30 s feature: 60 s for slow uploads
  2. Decide. Ask the author if unsure; here 60 is needed.
  3. Edit the file.
    timeout = 60 (markers removed)
  4. Test and commit.
    git add config.py git commit

Answer: keep timeout = 60, remove the markers, test, commit.

Common mistake: leaving the conflict markers in the file, or always choosing "ours" without reading.
✏️ Quick check · 1 of 8
Commits

A commit message that says "fix" with no other detail is a problem because:

What does a teammate need six months from now, reading this commit?
✏️ Quick check · 2 of 8
Branching

The main reason to create a feature branch instead of committing straight to main is:

What could go wrong if every half-finished change landed directly on main?
✏️ Quick check · 3 of 8
Merge vs rebase

Rebasing a branch that teammates have already pulled and built on top of is risky because:

What happens to other people's copies of commits that get rewritten?
✏️ Quick check · 4 of 8
Merge vs rebase

Cleaning up your own messy, not-yet-pushed commits into a tidy, linear sequence is a good use of:

Which operation is for tidying history you alone own?
✏️ Quick check · 5 of 8
PRs

A pull request mainly exists to:

What step sits between "pushed a branch" and "merged into main"?
✏️ Quick check · 6 of 8
Secrets

An API key was accidentally committed and pushed to a shared repository. The correct response is:

Does removing a file in a new commit erase it from earlier commits?
✍️ Type your answer · 7 of 8

A repository has 3 feature branches, each with 5 commits, merged into a main branch with 40 commits before them.

How many commits does main have in total after all three merges (ignoring any merge commits)?

Enter a whole number.
Add every feature branch's commits to the starting total.
✍️ Type your answer · 8 of 8

A team opens 18 pull requests in a week; 4 are rejected and closed without merging.

How many pull requests actually get merged that week?

Enter a whole number.
Subtract the rejected PRs from the total opened.
📝 Lesson quiz · 5 questions
0 / 5
Re-read the lesson, then give it another go.
Question 1 of 5

A commit is best described as:

Question 2 of 5

Merging two branches, keeping both histories intact, adds a:

Question 3 of 5

Rebase is risky mainly when used on a branch that:

Question 4 of 5

A pull request is where a team usually:

Question 5 of 5

A committed and pushed secret key should be: