git – pushing a new local branch to remote

Introduction

There are a few things that I have to do regularly in “git”, but have a gap of a few weeks between each time I do them. This gap is just long enough me to not bother remembering them, so I find myself googling these things again and again – so here’s the first of my regular but infrequent things I have to do in git…

Pushing a new local branch to remote

git push -u origin local-branch-name

which should give something like this…

Counting objects: 71, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (36/36), done.
Writing objects: 100% (37/37), 530.39 KiB | 365 KiB/s, done.
Total 37 (delta 28), reused 0 (delta 0)
To ssh://nas2/dw_git/rpd_deploy.git
 * [new branch] local-branch-name -> local-branch-name
Branch local-branch-name set up to track remote branch local-branch-name from origin.

 

Taking on WordPress software development work

I’ve been doing many and varied things over the last 3 years down here in Devon, most of it has involved software development in some form or another, and more than 50% of that has involved WordPress.

Now WordPress and I fell out a couple of years ago. I was (and still am) managing many installations of it, but despite doing everything humanly possible to lock it down, I had several episodes of hackers injecting phishing pages onto sites which cost me many unhappy hours to clean-up. I’ve always kept the sites as up to date as possible, but plugins inevitably lag behind which can preclude updating immediately.

Anyway – things have changed significantly over the last year or so. I have been increasingly impressed with WordPress and can say hand-on-heart I haven’t heard about a single site hack (to my knowledge!) in over 12 months on my or anyone I know’s sites.

The stability and security is a fantastic step forward, and with the releases since V3 it has become, more and more, a platform on which I’ve enjoyed developing.

What I’ve realised recently is, that a significant portion of our income is now coming either directly or indirectly from WordPress, and where-as before that would have worried me, now I find it quite exciting.

So I’ve taken the decision to actively position the Software / Web side of the business directly toward WordPress.

I’ve tested this by doing some freelance work on People Per Hour for the last few weeks focused exclusively on WordPress, and have been pleasantly surprised to discover there is enough WordPress development work on there to keep me very busy.

Now that I’ve proved to myself that the field is so active, and now I’m happy that the environment is stable, I’m going to dedicate a significant portion of the business time and money into developing WordPress plugins and doing bespoke and semi-bespoke software development for WordPress.

The work we’ve been doing recently has been so diverse it’s been a fascinating process and I’ve been able to work with some seriously interesting people.

Image

For example, when Paul from AutoRaceSponsor.co.uk gave us 5 out of 5 stars, he left this feedback for

me:

Dave is great operator – seriously talented in my view. Understands concepts up front and communicates solutions with great clarity and visualization prior to going ahead with code that delivers!

It’s nice to know the efforts are appreciated 🙂

So if you, or someone you know, needs a website to work ‘just-so’, then we’d be happy to develop a solution to your problem at a modest rate with great quality and fantastic service. http://www.davelopware.com/

Your own personalised social media url shortening

It’s something I’ve been thinking about for a while – ever since I discovered some old tweets I did that used ping.fm url shortening which doesn’t work anymore!!!

Well I finally had an excuse to code it when a client asked for the feature.

What I’ve done allows you to either generate a new short 6 character link, or define your own text for a better looking well-named URL.

I’ll knock one of these up for anyone for ÂŁ50 a year all inclusive of a domain name, hosting and google analytics on who clicks the links. So if you want to show off your impressive personalised short links in your social media marketing, just email dave@davelopware.com.

And best of all, this post can be the first thing I point to 🙂

 

Resignation as a Councillor from Ivybridge Town Council.

With some sadness, I resigned as a Councillor from Ivybridge Town Council effective 7th February 2012.

The last 9 months have given me the belief that the Council wishes to work in a significantly more ‘traditional’ way than I can cope with. For me personally email is a key aspect to how I work, and the only way I could hope to communicate with everyone I need to, given the hours I work.

I am physically unable to commit my time to face-to-face meetings for simple things such as raising questions, whilst still operating a business and hoping to still have a family life.

Before becoming a Councillor, I wouldn’t have believed that an organisation operating in today’s world, would or could take a strong position against using email. I do not believe, as some people have suggested, that there is any attempt to stifle debate or disclosure. Rather I believe that it can be explained in terms of people who are used to working in a different way and prefer to continue with the  familiar.

All that said and done, it has been very interesting being a Town Councillor. I have made some great friendships that I hope will continue. I have had the chance to learn about some amazing people who give so generously of themselves and their time for the benefit of others and with virtually no public recognition. I am still stunned and embarrassed at how little I can do compared to these fantastic people. Groups such as the Community First Responders (see http://goo.gl/pAixo and http://goo.gl/4skFB) who literally save lives!

Sure there have been frustrations, but in total it has been without doubt a positive experience.

I would recommend to anyone who wants to become more involved in their local area and help be part of the solution to challenges rather than just moan about them, to consider standing as a Local Town / Parish Councillor – and if you’re in Ivybridge, I happen to know of a vacancy 😉

Script for creating a Git repository on a Synology NAS from Mingw32 git bash

I’ve been making several small reusable chunks of code that I need in various combinations for a few different projects coming up over the next few months.

I don’t use any source control while I’m fathoming things out as the whole layout of the code can change every few hours. The most I do is a zip backup at the end of each day. But once the code starts to settle down then I get itchy if I haven’t got it in Git. So over the last two weeks I’ve created about 5 different Git repo’s, and what was a manual process became tedious.

I have a Synology NAS (DS210+) which I love. It’s got two 1Tb drives in a Raid 1 config (mirroring). It comes with ssh and I’ve installed Git on it which makes it an ideal in-house ‘remote’ repo.

So I wanted (yet again) to go from having a local directory full of code, to having it all in both local and remote Git repo’s all linked up nicely for push and pull. I’ve done this so many times in so many ways but never settled on a single ‘process’ and always end up googling to iron out wrinkles. So this time I scripted it up.

I run this from a Git Bash shell on my windows development machine. Works a treat so far, haven’t found any issues. I’m putting it here for my own future reference really – although others might find it a useful start for doing their own. I welcome any and all comments – it’s not perfect, but it does do what I need so far – all suggestions and improvements much appreciated though 🙂

#!/bin/sh

# Check the arguments
if [ "$#" -ne 2 ]
then
    echo ""
    echo "Usage: `basename $0` <reponame> <fromdir>"
    echo ""
    echo " reponame = the name of the repository to create"
    echo " fromdir = the directory from which to copy the source files"
    echo ""
    echo " example:"
    echo " `basename $0` supersouce.git experiment/supersource"
    echo ""
    exit 1
fi

#
# some basic config settings and naming the parameters nicely
#
# REPONAME is the name of the git repo to create locally and on GITHOST
REPONAME=$1
# FROMDIR is the directory from which initial source files are recursively copied
FROMDIR=$2
# GITHOST is the remote machine (synology NAS in my case) on which to create the remote repo
GITHOST=nas2
# GITBASE is the directory on GITHOST in which we will create the remote git repo
GITBASE=/dw_git/

#
# derived variables
#
# GITPATH is the complete unix path on GITHOST of our repo
GITPATH=${GITBASE}${REPONAME}
# RMT_BLD_FILE is the name of a script we create locally and scp to GITHOST and then exec via ssh
RMT_BLD_FILE=build-${REPONAME}.sh

#---------------------------------------------------------------------------------------
echo "$0 making local repository [$REPONAME] and remote on host [$GITHOST] in [$GITPATH]"
echo ""

#---------------------------------------------------------------------------------------
echo "Building script file to execute on [$GITHOST]"

echo "#!/bin/sh" > $RMT_BLD_FILE
echo "cd $GITBASE" >> $RMT_BLD_FILE
echo "mkdir $REPONAME" >> $RMT_BLD_FILE
echo "cd $REPONAME" >> $RMT_BLD_FILE
echo "git init --bare" >> $RMT_BLD_FILE
echo "cd .." >> $RMT_BLD_FILE
echo "chown -R root $REPONAME" >> $RMT_BLD_FILE
echo "chgrp -R grp_dw_staff $REPONAME" >> $RMT_BLD_FILE
echo "chmod -R 775 $REPONAME" >> $RMT_BLD_FILE

#---------------------------------------------------------------------------------------
echo "Copying script to $GITHOST"

scp $RMT_BLD_FILE root@${GITHOST}:~/

#---------------------------------------------------------------------------------------
echo "Executing script to $GITHOST"

SSHCMD="chmod +x $RMT_BLD_FILE ; ./$RMT_BLD_FILE"
ssh root@${GITHOST} $SSHCMD

#---------------------------------------------------------------------------------------
echo "Now creating local repository..."

mkdir $REPONAME
cd $REPONAME
git init
cd ..

#---------------------------------------------------------------------------------------
echo "Coping 'from' source files into our local repo ready for checking in"

cp -R $FROMDIR/* $REPONAME
cd $REPONAME

#---------------------------------------------------------------------------------------
echo "Add these files into local repo"

git add .
git commit -m"Initial commit"

#---------------------------------------------------------------------------------------
echo "Set the [$GITHOST] repo as remote to this one"

git remote add origin ssh://${GITHOST}${GITPATH}

#---------------------------------------------------------------------------------------
echo "Push all the files up to remote repo"

git push --all origin

#---------------------------------------------------------------------------------------
echo "Set the default branch for pulling"

git branch --set-upstream master origin/master

#---------------------------------------------------------------------------------------
echo "Quick summary of where we got to"

git remote show -n origin
git status

Or you can download it from here. Hope it helps 🙂

Princes’ Foundation Master Planning at the Watermark draws to a close

The initial phase of the intensive ‘Enquiry by Design’ process drew to a close last night (Thursday 10th November) at a Public session entitled “Presentation of the Two Masterplans”.

The event was very well attended (the large hall in the Watermark was at maximum capacity) and personally I felt the mood of the room was warm and interested.

My understanding is that the next phase involves the Plans that the Princes’ Foundation proposed, will be brought together and made publicly available in a way that everyone can view, discuss and give their feedback on. All of which I’m very much looking forward to.

In the mean time a discussion about peoples thoughts at last nights meeting has started on Ivybridge Matters…

http://ivybridgematters.org.uk/groups/_ivybridge-general-chat/forum/topic/masterplanning/