Linux Labs

Automation: Git and Ansible / Stage 2 of 6

Config from a repository: pull and conflicts

Not running Starting usually ~20 s
Leave the lesson

Step 3 of 7 · on a machine · 5 min

Set the edit aside and update

An edit that blocks pull does not have to be thrown away: you can set it aside, update and bring it back.

git stash saves uncommitted edits to a separate list and puts the files back to the last commit. After that git status is clean, and pull goes through: the branch simply moves forward to origin/main — a fast-forward, with no merge. git stash pop lays the saved edit on top of the new files and removes it from the list. git stash list shows what is set aside right now (in the Wiki).

bash
# set edits aside, files go back to the last commit
sudo git stash
# bring the set-aside edit back on top of the current files
sudo git stash pop

pull and stash change only files. The running nginx does not know about them until it rereads its config: sudo nginx -t and sudo systemctl reload nginx.

Exercise · do it

Update the server and keep the edit

In /etc/nginx/conf.d set the local edit aside, pull the update from the repository and bring the edit back into the file. Apply the config: the new page http://127.0.0.1:8080/status must answer.

Sign in and start The machine is available after signing in

Goals · 0 of 3

  • Update the working copy from the repository not done yet
  • Bring the local edit back into the file not done yet
  • Apply the config in the running nginx not done yet

Step goals

0 of 3
  • Update the working copy from the repository — not done yet
  • Bring the local edit back into the file — not done yet
  • Apply the config in the running nginx — not done yet
Ubuntu 24.04

Step goals

0 of 3
  • Update the working copy from the repository — not done yet
  • Bring the local edit back into the file — not done yet
  • Apply the config in the running nginx — not done yet
Loading…