Rewriting Git history

The other day I made about 30 commits to a project without realizing my editor was adding spaces to the files even though they mostly contained tabs. I really couldn’t care less whether files have tabs or spaces, but consistency is the important thing, so I decided to rewrite my history using git’s filter-tree option.

This command checks out each original revision, and makes the changes specified, then commits that as a new revision. In this case I replace a tab with 4 spaces in every .cs file. I start from origin/master and go up to the currently checked out commit (head):

git filter-branch --tree-filter "find . -name '*.cs' -exec sed -i -e 's/\t/    /g' {} \;" origin/master..HEAD

You can run an arbitrary script (perhaps run it from a different file if it’s longer than this though!). Here’s another example using git diff to check which “.cs” files were new or modified in the range I’m rewriting, which I then pipe to sed and replace a tab with four spaces.

git filter-branch --tree-filter "git diff --name-status master HEAD | egrep ^[AM] | grep .cs | cut -f2 | xargs sed -i \"s/\t/    /g\"" master..HEAD

This one won’t deal well with files that are created anywhere except the first commit. I’ll leave that as an exercise for the reader 😉

Posted in Note to self | Leave a comment

Hypothesis, Measurement, Decision

“Build Measure Learn” is a popular mantra from the Lean Startup world and it’s a great way to structure things. There’s extensive advice on getting it right, unfortunately though, to me, the words don’t have the right connotations when condensed down like that. So here’s how I think of it:


X% of [specific potential customer segment] need/desire [specific value proposition]
Imagine you already have the results, would it let you decide what to do next?

When aiming for product fit, a nice way to find an area of focus is by plotting your assumptions on a risk matrix, evaluating the impact and likelihood of being wrong.


The quickest/cheapest way to get feedback
e.g. Survey? Ask users to sign up if they’re interested?

If the answer seems like “build it”, figure out how you’d make people aware of the thing you built, and how you’d get evidence of your hypothesis from that. Ask yourself, do you really still need to build anything for that plan to work? Or could you just tell people you’re thinking of building it and ask them to make a commitment such as giving you their email address or time to prove their interest?

Sometimes the answer really is “build it”, so build the smallest thing that could give someone in that customer segment just enough to see the value proposition and give you the feedback you need to proceed.


Summarize learning, shuffle priorities, set the direction to go next, then start the loop again.


Using it

Hopefully it’s pretty obvious how to follow this step-by-step when you have 1 big idea and 0 products on the market. You find the best way to test the assumptions behind that idea, and reshape the idea based on that learning until the best way to learn more is to implement that idea. This can work very similarly for new features.

Once you establish a customer base and need to make tweaks and bug fixes you can use the same framework, but choose your area of focus based on customer retention rather than product fit. You will likely already have some evidence for the “measurement” part.

Sometimes the expected implementation+maintenance cost is below the cost of further research. In which case:

  • Make sure you deliver some value as early as possible to give you a chance of changing direction when you’re wrong, or when the world changes under your feet.
  • Identify the measure of your success. Imagine you’ve shipped the wrong thing, then pick a hypothesis that would let you know which assumption was faulty or what to do next. Make sure you’re collecting that data!



I like to think this blog post provides a small chunk of value. I’ll be watching for page views and messages to decide whether to delve deeper at a later date 😉


Posted in Note to self | Tagged , | Leave a comment

My Git setup on Windows

GitExtensions – Free, cross-platform Git UI giving good visibility of the relationship between commits/branches while providing the power to achieve most everyday functions (commit, merge, interactive rebase, and many more)

Tip: During installation, choose the option which integrates with the windows command prompt by adding Git’s user\bin directory to your PATH.

PoshGit – Contextual information in powershell about the current branch

Tip: Set an environment variable GIT_SSH to be "C:\Program Files\Putty\PLINK.exe" to use putty for SSH from Powershell.

Posted in Note to self | Leave a comment