Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Hoofdstuk 5Naam in de cursus: Rebasing

Keep a clean history with rebase

Rebase moves your commits on top of another branch, as if you had started your work there. The history becomes one straight line — easier to read and review. Interactive rebase also lets you clean up commits before you share them.

  • 5 Lessen
  • 2 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

5.1

Rebase a branch on main

While you worked, main moved on. Rebase replays your commits on the new main.

git switch feature/web-network
git fetch origin
git rebase origin/main
git push --force-with-lease
before:   main  A---B---C
                 \
          feature D---E
 
after:    main  A---B---C
                         \
          feature         D'--E'

Onthoud

Rebase rewrites commits (new hashes D', E'). Never rebase commits other people already built on — only your own feature branch.

Commando's in deze les

5.2

Solve conflicts during a rebase

A rebase stops at each commit that conflicts. Fix it, then continue.

git status
vim main.tf
git add main.tf
git rebase --continue
git rebase --skip
git rebase --abort

5.3

Clean up commits interactively

git rebase -i opens a list of your commits. Change the word in front to squash, reword, reorder or drop commits — before you open the pull request.

git rebase -i origin/main
Editor during git rebase -i
pick 1a2b3c4 Add web subnet
fixup 5d6e7f8 typo
pick 9a8b7c6 Add NSG rules
reword 3c4d5e6 wip
drop 7f8e9d0 debug output
WordEffect
pickKeep the commit
rewordKeep, change the message
squashJoin with the commit above, edit the message
fixupJoin with the commit above, keep its message
dropRemove the commit

Op het werk

Commit with git commit --fixup=HASH while you work, then git rebase -i --autosquash origin/main puts every fix in the right place.

Commando's in deze les

5.4

Choose merge or rebase

Both bring changes together. Teams pick a style and stick to it.

MergeRebase
HistoryTrue, with merge commitsStraight line
Safe on shared branchesYesNo (rewrites)
ConflictsOncePossibly per commit
Common useMerging a PR into mainUpdating your own feature branch

5.5

Pick single commits

git cherry-pick copies one commit from another branch — for example a hot fix from main into a release branch.

git switch release/1.2
git cherry-pick 3f2a9c1
git cherry-pick -x 3f2a9c1

-x adds "cherry picked from commit …" to the message, so the link is clear.

Commando's in deze les

Alle commando's in dit hoofdstuk