Reputation: 596
I can't seem to find anything to help my situation & was hoping someone could help me as I'm not entirely fluent with git yet but am loving it.
We have a dev server under git control displaying our dev branch. We then have a master branch in addition to to the dev branch which has a stable version of the website.
Then, on our production server we have our stable site but due to how things played out, it is not under git version control, we have just manually updated the files we needed. Obviously the stable master branch files look somewhat similar to the manually managed production set of files.
We'd like to eventually get the production server under git control, displaying the master branch, just like the dev server reflects the dev branch.
However, I'm not sure how to go about setting up the git repo on the production server and somehow merging it with the master branch. Could anyone please provide some pointers, hints or direction?
The only thing I found online involved something along the lines of setting up another two repos (for a total of 3), one being a parent of the other two and somehow bringing them all together that way. I was hoping for a different solution (or at least a "ya, that's correct" so I don't go down some stupid rabbit hole. ( not sure if this Merging two folders using git might be some sort of start?? but the lack of responses made it hard to see if that was the right thing to pursue )
Thanks all.
Upvotes: 4
Views: 1664
Reputation: 5996
If I got you correctly the site on your production server is based on your master branch (or some other commit in your git repo) but not exactly the same, i.e. with some manual changes in it and you don't want to lose this manual changes. Here is what I do in cases like this:
git diff
to examine all changes and commit the relevant ones.git merge master
with your master.I hope I understood you correctly and this guides you in the right direction.
Upvotes: 2
Reputation: 84393
You can't reliably push to a repository with a working directory. You will get errors about non-bare repositories, and fighting the system will be bad for your ulcer.
What you ought to do is:
git clone
from your production machine.git pull
as a cron job.As long as you don't make manual changes in the Git working tree on your production machine, you won't have to do anything other than git pull
when you want to roll out the latest changes. Just remember: pull from your production system, don't push to it.
Upvotes: 0
Reputation: 18716
You don't have to version the production server: it should already be versioned!
What you need to do is having one single repo, that will be deployed everywhere: production server, staging server, local dev machines, etc.
You'll work locally however you want, but in the production server, you'll simply stay on the master branch.
Locally, when you finish working on something, and it is fully working, tested, etc. Simply rebase (or merge) it into (with) master, and git push origin master
it. Then, on your production server git fetch && git rebase origin/master
(or pull) to get the changes.
Upvotes: 0