We use Git to manage and deploy code. I’m on the Ops team and I do deployments. Our developers make changes and push code into Github, and we (Ops) use some managed processes to pull production code and deploy it.
The process is like this:
Background
- Developers do stuff. That stuff ends up in Github and the Devs tell us so.
- We have a local “staging” clone, and a local “deployment” bare git repo. The local git clone has two remotes, Github as “origin” and the local bare repo as “deploy”
- We use chef on the web servers to actually deploy the code via the chef git resource that pulls from the “deploy” remote
- We have the “deploy” remote so that there is a gating mechanism between Dev finishing stuff and our deployment timing. (Rather than deploying from Github directly)
Actual deploy Process
cd into local clonegit checkout branchnamegit pull origin branchnamegit push deploy branchname
All of this is partially automated, and is moving to full automation. As such, we are careful to not ever make local changes to the staging clone, and we expect that the output of git status in that clone will only ever be nothing to commit (working directory clean)
However, we had a weird message come up this week. The deploy clone is stating that it is 80 commits ahead of origin! Even though it also says nothing to commit.
# On branch branchname
# Your branch is ahead of 'origin/branchname' by 80 commits.
#
nothing to commit (working directory clean)
Finally, there isn’t really a problem, per se. The commit SHA256 hash matches in this clone, and on the deployed code on all of the web servers. I didn’t do an actual rsync comparison, but I’m pretty confident that the actual code itself is deployed correctly.
I want to know how this could happen, if it is bad, and how to clean it up short of deleting the local clone and starting over.
If both
deployandlocalrepos have been cloned from the same ‘origin‘ (GitHub), your process shows that onlylocalis doing agit pull origin.The repo
deploynever fetches anything fromorigin(it only receives commits fromlocal).That means
deploystill believe having commit that would not be on origin (at least the origin it knows about).A simple
git fetch originexecuted from thedeployrepo would make that status cleaner.