views:

44

answers:

3

I've been finding lately that often I will want to go off and hack at some new idea I have (as a new project), and if in an hour or so it looks promising, I will keep it. If not, I will trash it.

My question, then, is when should I start tracking these little experiments? From the very beginning, like with hg init revolutionary_idea, or after I decide I should keep it?

Right now, I am waiting until after I flesh out whatever idea has popped into my head, then initializing and committing, because I don't want to be thinking "should I commit now?" every other save.

On the other hand, though, if I commit regularly from the beginning, then I will have a very detailed timeline of everything I've done and why.

On the third hand, if I track from the beginning, and don't commit until I know I want to keep it, then it would be no different from just doing an initialization later on, right?

What do you guys think? What is the "best practice" in this case?

A: 

I git init right after generating a new project. Git is so effortless, there's no reason not to do it. I'm continually branching, committing, merging, etc. It's just an easy way to do something and you don't have to worry about failed experiments or anything, because they can easily be undone.

So in my opinion, if you aren't using version control all the time, you're doing it wrong. Except for single-file scripts and really quick little demonstration programs. I don't bother using git to track those.

AboutRuby
A: 

As explained in DVCS - How often and when to commit changes, you can commit as many times as necessary in a private branch (i.e. a branch you will not publish/push elsewhere).

When you know you want to keep a particular line of development, then you can reorganize your commits into logical commits (each ones representing a stable state, passing unit testing for instance) or simple merge --squash the all thing.

Don't go to extreme though: it doesn't make sense to commit after every save with a DVCS.

VonC
Well, those are some good links except that: one, they don't answer my question; and two, I'm using Mercurial, so are there equivalent operations in Mercurial?
Austin Hyde
@Austin: sorry about that, I didn't catch the `hg` command right away. Those links illustrate the basic answer to your question: start tracking as soon as possible. No need to wait for a stable state. Regarding Mercurial, rewriting history [is possible](http://stackoverflow.com/questions/3178291/how-does-mercurial-work-with-many-developers/3178656#3178656) (rebase, transplant, queues), [even though it is not always recommended](http://stackoverflow.com/questions/504409/is-it-worth-the-effort-to-create-pretty-revision-history-in-a-dvcs/510123#510123).
VonC
A: 

Usually, if I'm starting something, the first thing I do is create the repository. Creating the repository is so light weight with git and hg that there's nothing lost by doing it, and so much to be gained.

If it turns out the new project isn't going anywhere, you can just delete it, repository and all.

haydenmuhl