so here's the real reason i started it — nothing too exciting, but after a hunch of a discussion it simply had to go somewhere... :)
since i just figured the below out for the second time (after forgetting what the suitable git commands were since the first time a few months ago) i thought i might as well write it down. perhaps it'll come in handy at some point... :)
imagine you're offline, in a train or plane or cafe, and feel like getting some work done. you're starting to make changes and quickly realize you'd rather split things into several commits than just a single big one. however, you're working against a subversion repository and have — since you're offline — no way to commit things back right away or (conveniently) keep the patches separate. well, except perhaps for copying the whole directory for every single one and later merge/commit them one by one. not really worth the trouble... but git to the rescue!
even without a previously cloned svn repos it's quite easy to locally commit away and later replay your changes. here's a quick step-by-step howto:
- initialize an empty git repos, propbably best done in the top dir of your working tree:
$ git init
$ git add * $ git commit -m 'import'
$ vi ... # or emacs if you must ;) $ git commit -a
being offline you leave it at that. once you're back online you wanna transfer those changes to svn, or, iow, apply them to a cloned git repository:
- format/export the patches you've made (the rev specifier ":/import.." translates to "between a commit starting with 'import' and head) to separate files:
$ git format-patch :/import..
this will output numbered files, one file per patch, like:0001-fix-1.patch 0002-fix-2.patch ...
- remove your temporary git repos (or move it out of the way):
$ rm -rf .git
$ git svn clone svn://svn-url
$ git am 00*.patch
$ git svn dcommit
No comments:
Post a Comment