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 7Naam in de cursus: Git tools

Use stash, tags, bisect, blame and worktrees

Git has tools for the moments that do not fit the normal flow: put unfinished work aside, mark versions, find the commit that broke something, see who changed a line and why, or work on two branches at the same time.

  • 6 Lessen
  • 3 Commando's

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

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

7.1

Put work aside with stash

git stash saves uncommitted changes and gives you a clean working tree — for example to fix something urgent on another branch.

git stash push -m "half-done NSG rules"
git stash list
stash@{0}: On feature/web: half-done NSG rules
git switch main
git switch feature/web
git stash pop
git stash push -u
git stash drop stash@{0}

-u also stashes untracked files.

Commando's in deze les

7.2

Mark versions with tags

A tag is a fixed name for a commit, usually a version. Annotated tags have a message, an author and a date.

git tag -a v1.0.0 -m "First production release"
git tag
git show v1.0.0
git push origin v1.0.0
git tag -d v0.9.0-test
git push origin --delete v0.9.0-test

Onthoud

Modules and pipelines often use tags as versions (?ref=v1.0.0). Never move a tag that others use — make a new one.

Commando's in deze les

7.3

Find the bad commit with bisect

git bisect does a binary search through history: you say "good" or "bad" for each commit Git picks, and it finds the first bad one fast.

git bisect start
git bisect bad
git bisect good v1.2.0
git bisect good
git bisect bad
git bisect run ./test.sh
git bisect reset

With git bisect run SCRIPT, Git tests every step itself (exit code 0 = good).

Commando's in deze les

7.4

See who changed a line

git blame shows the last commit for every line — to find why something was changed, not who to blame.

git blame -L 20,40 modules/network/main.tf
git log -S "0.0.0.0/0" --oneline
git log -L 20,30:modules/network/main.tf

git log -S TEXT finds the commits that added or removed a text — great for "when did this rule appear?".

Commando's in deze les

7.5

Work on two branches at once

A worktree is a second working folder for the same repository — no need to stash or clone again.

git worktree add ../infra-hotfix hotfix/dns
cd ../infra-hotfix
git worktree list
git worktree remove ../infra-hotfix

Commando's in deze les

Alle commando's in dit hoofdstuk