Git and staging: a realisation
Despite having used git
on small projects for quite a while, I'd always felt that I'd simply taken my experience from my previous versioning system — I'm a long-time CVS maven — and simply mapped into corresponding git commands. And although I'd skimmed through enough of the Git Book
to make this work, I wasn't entirely sure I understood some of the more esoteric features.
Finally having a project large enough to experiment with — and having built up enough confidence to know how to clone and pull without damaging my master copy — I decided to spend a little time working with the book to firm up my theoretical understanding of what was actually going on.
Almost immediately, I had a revelation: I'd completely misunderstood staging.
Moving from CVS, I'd assumed that
simply notified git that the specified file was under version control. I'd also assumed, again from CVS, that I either needed to supply the full path to each file I wanted to commit or use
git commit -a
to push the lot. But I quickly realised that what I'd actually done was to hit on a particular set of options that combined the two steps of moving the file to the staging area and committing it to the repository.
So I'd actually been missing a really useful feature: the ability to stage up copies of particular files ready for a commit whilst still working on others — something that seems extremely well suited to my usual cyclical method of debugging and testing.Tags: git