Some kind of source control is a good idea for all sorts of reasons, not least of which it means you can roll stuff back easily if you make a major f**k up!
First of all read this guide to git – no deep shit.
Now go and get an account on github.com
I’ll update this when I get more time but for now that’s enough to get started.
Send in the Clones
OK I have to be honest here this next bit is mainly for my benefit in case I need to refer back to it but hopefully it will help someone else as well.
I’m working on a WordPress Plugin at the moment which I need to test on several websites locally so I can see if anything is going to go bang before I roll it out on live websites. So rather than having one folder containing a clone and creating a branch for each development sprint I needed to have several folders in my /var/www/ folder. After Googling around a bit I found this solution which was very helpful.
In short here’s what’s involved.
- Create a repository. This will be your master copy, or big kahuna or whatever.
- Clone a copy of your master repository into /var/www or whatever nasty windos/Mac thingy you’re using.
- Create a branch for each of your websites. So if you have for example http://localhost/website1 , http://localhost/website2, http://localhost/website3 etc, then create a branch for each one with a sensible name.
- Create a clone in each website folder and checkout the respective branch for that website.
I’ll add more notes here as my learning curve gets smaller.
Oh and as always RTFM
OK so I have made some changes to my local branch “master”. I’ve commited those changes using git commit -a. Those changes were then “pushed” to the remote repository using: git push remote master. I’ve now begun testing on the first of my local branches. This involves navigate to that instance of the plugin in my /var/www/ folder and running git branch to check which branch I’m working on. The next step was to replace my local branch files with the updated master repository on the remote server by running git pull remote master.
Watch this space for further updates.
Pushing the Changes
I found this entry on stackoverflow.com very useful today this. Mark Longair provides a straightforward explanation of how you go about merging the changes in your local branch to your remote master reposiotry.
To merge your local branch “development” with your local branch “master” then push though changes to your remote repository you would do the following:
git checkout master
git merge development
git push origin master