Git: is there a good workflow for rapidly prototyping code

602 Views Asked by At

I often spend time 'experimenting' with code, rapidly prototyping different ideas before deciding on a final approach; but I'm struggling to find a good workflow that supports "checkpointing" my progress.

Using git I can easily commit at any stage, but jumping back and forward between commits on a branch rapidly becomes frustrating as I end up on headless branch and it's easy to lose further commits as they're not really tracked anywhere. Creating multiple branches like "featureA_simple_threshold_20", "featureA_simple_threshold_10", "featureA_complex_threshold_42" alleviates that problem, but leads to (what seems to me) a very messy workspace; and that's before conflicts start.

I've had a look at the recipy package for Python: https://github.com/recipy/recipy which is similar to what I'm looking for, but relies on persisting array-like objects, while I'll often just have a handful of print statements for my results.

This seems like it should be a pretty common use case, so are there any good workflows that can be recommended? Is there an alternative tool that could help me out here? (I'm primarily developing in Python, but this seems like a non-language specific problem)

1

There are 1 best solutions below

2
On

Creating multiple branches like ... alleviates that problem, but leads to (what seems to me) a very messy workspace;

Messy if you keep only one workspace.
But since Git 2.5, you can have multiple workspaces (one per branch) for one cloned repo. See "Multiple working directories with Git?".

Once you decide on a final approach, you can make that branch your main branch.