Good times with git
[Permalink] blog git
Having relatively recently moved to using git for version control, I've been thoroughly loving it :)
(By the way, I thoroughly recommend this document for getting to grips with git)
I don't know how other people work but in my place of work (at least on the project I'm currently working on ), we're using a system of one branch per major version, a branch for testing, and a branch for each developer. That doesn't preclude other branches of course, I frequently create local branches for new features or other things which are liable to break things.
This system gives us a very easy means of deployment to servers running different "flavours" of the code-base (e.g. stable, unstable, testing) by checking out a specific branch. Of course, we then use fabric to quickly do a
git pull on server(s) when there's an update.
One feature of this way of working is that often find myself performing the following exact sequence of git commands:
git checkout testing git merge stilvoid git checkout stilvoid
to get the latest changes from my working branch into testing ready for deployment and testing in our test environment.
I don't like repeating myself.
Enter: git aliases!
I'd heard about git aliases before but I'd only seen them in the context of aliasing
git ci to
git commit or similar; not for creating an alias for a sequence of git commands.
Anyway, after a few minutes of playing about, I came up with the following which I hope to be of some use:
git config --local alias.merge-to '! BRANCH=$(git branch | grep "*" | cut -d " " -f 2) && git checkout $1 && git merge $BRANCH && git checkout $BRANCH && echo Merged to'</pre>
So that I can now run
git merge-to testing to achieve the same as the sequence I mentioned earlier :)