Hacker News new | ask | show | jobs
by gknoy 3494 days ago
Recovering from a lisp image is pretty darned cool. :D

> I had a lot of unchecked work - about a weeks worth > ... It is the second time I have lost work by misusing git

I realize this is _off topic_, but one thing that helps me a lot is making regular small commits (that describe some small idea of the change), and then rebase them later once I get all the linting / tests fixed. (Obviously not on master ;)) It's easy to go too-granular here, but it's very handy to be able to reorder the commits, or squash "fixup" commits, to make things easier to review.

I spend more time rebasing than I probably need to, but on the other hand I've never lost work. ;)

For example (adapted from a PR I was working on this morning ;))

    git commit -m "Add Clone Foo feature"
    git commit -m "Reorganize tests"
    git commit -m "Fix indentation"
    git commit -m "Add generator for Baz items"
    git commit -m "Add test of Clone Foo feature"
    git commit -m "fixup linting in application"
    git commit -m "fixup test linting"
    git commit -m "fix Foo test to use correct selector"

    git rebase --interactive master
    # reorder fixup commits, squash them together with the things they fix
You can always rebase and squish all of these down into one commit later before you make your pull request (or, leave them as-is if your team is OK with un-squished PRs).
2 comments

> # reorder fixup commits, squash them together with the things they fix

The --autosquash option of git rebase can save you some work:

       --autosquash, --no-autosquash
           When the commit log message begins with "squash! ..." (or "fixup! ..."), and there is a commit whose title begins with the same ..., automatically modify the todo list of rebase -i so that the
           commit marked for squashing comes right after the commit to be modified, and change the action of the moved commit from pick to squash (or fixup). Ignores subsequent "fixup! " or "squash! " after
           the first, in case you referred to an earlier fixup/squash with git commit --fixup/--squash.

           This option is only valid when the --interactive option is used.

           If the --autosquash option is enabled by default using the configuration variable rebase.autoSquash, this option can be used to override and disable this setting.
(Not off-topic for me. :-)) I will have a play with all this. Now that I have my source being backed up to zfs I can be a bit more comfortable with experimenting with new workflows.

Thanks