we have a Git remote repository (in a way, our “central” repository) on the server of our site and the site is run off that repository. Just pushing to the repository does not update the site, we have to run a little script on the server first.
Now I want to display a little warning when there are new commits that haven’t been applied yet. Which Git command can I use to find out whether there are commits that have been pushed but not yet applied?
You could store the SHA of the commit that is currently “live” on the site, and then compare it with the SHA returned by
git rev-parse <name of remote>/master.(You may need to run a
git fetch <name of remote>first to make sure you have the latest info for that remote.)