A quick bash script to make feature branching a bit easier
Mike Dixon
During a typical working day I can easily flip between 15 projects, fixing small bugs or working on various features. Each flip normally requires a new feature branch, and i found myself repeating myself. A lot. I'm a parent so I'm pretty used to this, but in this instance I figured I could probably do something about it - so put together a simple bash script.
#!/bin/bash
git pull
git checkout -b feature/$1
git push origin feature/$1
git branch --set-upstream-to origin/feature/$1
This will do a pull on the current branch, create a new feature branch (using the name I pass in as an argument) before pushing the branch up to github and then setting the upstream origin.
I originally had a git checkout production line at the top, but then figured actually I needed to take my feature branch of master sometimes so removed that.
So now - when I jump onto ticket 12345 - I just run
git checkout production
go 12345-my-branch-name
And hey presto - all ready to do some actual coding.