Reputation: 695
I have a bit of a strange scenario occurring & I'm not sure exactly how to diagnose the issue.
Overview
I have 3 environments that have been initialized as git repos:
Staging is a git clone of Production and Dev is a git clone of Staging. The intent of the workflow is to allow for any number of local development environments (Dev) which can then be pushed to the staging repo (Staging) for review. Once reviewed and approved, I can then push from Staging to Production.
Problem
When cloning the Staging repo to a local Dev environment, clone works fine. But when local changes are committed on Dev and then pushed back to origin/master on Staging, the changed files from the Dev commit are are not being applied.
When I run git log
on the remote server my Dev commits are being show in the history, they're just not being "applied" (i.e. the file changes from my local dev environment are not being applied to the remote origin/master). But, oddly enough - On local Dev, if i make a change to a file, commit & push to Staging origin/master and then run git status
on Staging, the files from the Dev Commit show as being "staged".
I have absolutely no clue what's happening here. I tried cloning an entirely new dev repo from staging and the same issue occurs.
Here are my git config settings for each environment:
Production Config (remote)
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[receive]
denyCurrentBranch = ignore
Staging Config (remote)
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[receive]
denyCurrentBranch = ignore
[remote "origin"]
url = /home/xxx/public_html
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
Dev Config (local)
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = ssh://[email protected]:port/home/username/staging/1
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
Upvotes: 2
Views: 123
Reputation: 38669
It is a very bad idea to push to a non-bare repository and such pushes will not automatically update any worktree as you observed. This is normal and expected behavior.
Git is not a deployment tool, but you can build one around it (in simple environments) or use it as an object store (for complex ones). Here are some options / ideas to get you started: http://gitolite.com/deploy.html
Upvotes: 2