Reputation: 14605
I use Git to manage the source code for my (iOS) project, which I've been doing now for a while which works great. However I'm now beginning to add a server-side component, and I'd like to make sure that the server-side code is kept in the same repository, but separated from the main code-- and set up on the web server so that the whole codebase and history won't be accessible. What's an ideal Git workflow to work with codebases that are on two computers, one local and one sitting on a web server? (By the way, I'm using Nginx if that makes any difference in terms of how to set it up for the server configuration to hide Git files and history.)
Upvotes: 2
Views: 308
Reputation: 12629
As to the first question, how to track client and server sides together in a way that the server side is still a standalone project. You could incorporate the server code as a submodule into the client project.
~/client$ git submodule add foo@bar:server.git
~/client$ git commit
This inserts the server repo, accessible at SSH URL foo@bar:server.git
into your client project into subdir server. An alternative of submodules are subtree merges.
As to checking out the server code into nginx. Create a bare repo somewhere on the server, let's say /var/git/server.git, and set up its worktree into /var/www/server/
cd /var/git
mkdir server.git && cd server.git
git init --bare
git config --bool core.bare false
git config --path core.worktree /var/www/server/
Set up its post-receive hook to check out the worktree to the new HEAD.
echo '#!/bin/sh' > hooks/post-receive
echo 'git reset --hard HEAD' >> hooks/post-receive
Set up a remote in your development pointing to the above:
client/server$ git remote add www root@bar:/var/git/server.git
client/server$ git push www master
Or something like that...
Upvotes: 2