<div class="gmail_quote">On Wed, Nov 2, 2011 at 2:23 PM, Trevor Cordes <span dir="ltr">&lt;<a href="mailto:trevor@tecnopolis.ca">trevor@tecnopolis.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Here&#39;s the copies I currently have that I&#39;d like to git-itize:<br>
<br>
1. Raw dev copy on my box<br>
2. Testing copy on production server<br>
3. Live copy on production server<br>4. 2nd dev copy on some other guy&#39;s server<br>5. git &quot;master&quot; copy somewhere on production server<br></blockquote><div><br></div><div>You&#39;ll want to set up what&#39;s called a &quot;bare repo&quot; somewhere. A bare repo is basically the contents of the .git directory with none of the working files. git init --bare does it, or you can set up a git server. Gitosis-lite is easy to use and only takes a bit of time to set up. Or pay a few bucks and use <a href="http://github.com">github.com</a> or another service. This is what you will think of as your master copy. No one ever touches it directly. </div>
<div><br></div><div>Everyone will clone the repository locally with something like</div><div><br></div><div>git clone git@git.yourdomain.com:yourapp.git</div><div><br></div><div>This will create a local copy of the repo with a remote called &quot;origin&quot;. Everyone works locally, commits, then pushes stuff to origin.</div>
<div><br></div><div>(make local changes)</div><div>git add .</div><div>git commit -m &quot;fixed bug #71&quot;   # now it&#39;s committed to my local repo</div><div>git push origin master # now it&#39;s committed to the master</div>
<div><br></div><div>other guys can</div><div>git pull origin master # now I have your changes</div><div><br></div><div>Git doesn&#39;t have &quot;different copies&quot;. Everyone has the same thing, and you use branches to figure out what your working copy looks like.</div>
<div><br></div><div>For your different users, you have to decide which branches mean what. I follow the continuous deployment model which means that master is always in a &quot;ready to push&quot; state. I usually create &quot;topic branches&quot; to do work and merge them back in to master when I&#39;m happy. Usually these topic branches stay local, but if I want to share changes with other developers I can push the branch itself (which is just a pointer) to the origin server and the other devs can see what I&#39;ve got.</div>
<div><br></div><div>So if I&#39;m a developer, my procedure would be</div><div><br></div><div>git pull origin master # update to the latest code</div><div>git branch myfeature # change to a new feature</div><div>(implement myfeature)<br>
</div><div>git add .</div><div>git commit -m &quot;implemented myfeature&quot;</div><div>git checkout master # get back on to master, my changes disappear</div><div>git merge myfeature # merge the changes from myfeature onto master</div>
<div>git push origin master # on to the server</div><div><br></div><div>(it seems verbose, yes)</div><div><br></div><div>So for your staging and production servers, you would update master from origin as needed (first staging, verify, then prod) in two separate clones of the repo.</div>
<div><br></div><div>None of this requires post-commit hooks. People only log in as git to update their local repos, never interactively.</div><div><br></div><div>(feel free to talk to me off list if you need more details)</div>
<div> </div><div>Sean</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I&#39;d love some help with confirming this structure will work with git<br>
and maybe some tips on actual git commands to get it going.  The 2<br>
developers have full shell access on the production server.  I&#39;ve setup<br>
a &quot;git&quot; user on it too, which both users can access if required.<br>
<br>