The team keeps the lab-site config in a shared repository /srv/git/lab-site.git, and the /etc/nginx/conf.d directory on the server is its working copy. This morning a colleague pushed a new /status page to the repository, and the server needs updating: fresh commits are fetched by git pull. Try it — and see what state the working copy is left in.
Try to update the server from the repository
In /etc/nginx/conf.d pull the update from the repository, then look at the state of the working copy.
First, predict
The repository has a new commit, and on the server someone edited the same file without committing. What will sudo git pull do?
Now start the exercise, run the command and compare your prediction with the output.
git pull downloaded the colleague's commit but did not bring it into the files. What stopped it?
-
The commit is downloaded: status says “behind by 1 commit”, and
sudo git log --oneline HEAD..origin/mainshows it. The refusal is at bringing it into the files. -
The command ran with
sudo, as root. A permission error would read “Permission denied”, while git said “would be overwritten by merge”. -
The lines differ: the commit adds
/statusat the end of the file, the edit addsaccess_lognear the top. git refuses on any uncommitted edit to a file the new commit changes.
git does not overwrite an edit that is not in the history and refuses to bring a commit into such a file.