How to get the deployed Git commit hash in Portainer CE

When Portainer Community Edition deploys a stack from a git repository , it clones the repo, runs docker compose up , and then deletes the .git directory . This means the usual git rev-parse HEAD trick doesn&rsquo;t work inside the running container &ndash; there&rsquo;s no git history left. But Portainer does remember the commit it deployed. The stack API endpoint exposes it in…