git remembers snapshots of the config and compares the current files with them — that is how you see exactly what was changed by hand.
The .git directory inside /etc/nginx is the repository: it holds the history. The history is a chain of commits. A commit is a snapshot of all files at the moment it was recorded, with an author, a date and a message saying what and why. The files next to .git are the working files: nginx reads them, people edit them.
git status compares the working files with the last commit and lists the changed ones. The changed lines come from git diff in diff format: - is how it was in the commit, + is how it is in the file now. That matters when you chase an error: nginx names the line where parsing stumbled, and git names the lines that were changed. They are not always the same.
git restore <file> throws an uncommitted edit away: the file becomes what it was in the last commit. An edit that is not in the history cannot be brought back after that.
The repository belongs to root, like the config itself, so git runs with sudo here. Without it git refuses: “detected dubious ownership” — it does not work in someone else's repository until the owner matches the user (in the Wiki).
Put the file back to the last commit
In /etc/nginx see exactly what was changed in conf.d/lab-site.conf since the last commit, throw that edit away and start nginx.
Goals · 0 of 2
- Put conf.d/lab-site.conf back to the last commit not done yet
- Start nginx not done yet