{"thread":{"id":"27758","subject":"Getting git to help my memory","startedAt":"2011-07-05T21:34:18Z","lastAt":"2011-07-06T07:52:40Z","messageCount":4,"participants":["Evan Driscoll","Paul Ebermann","Ben Walton","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"170843","messageId":"loom.20110705T232905-603@post.gmane.org","threadId":"27758","inReplyTo":null,"subject":"Getting git to help my memory","fromName":"Evan Driscoll","fromEmail":"driscoll@cs.wisc.edu","sentAt":"2011-07-05T21:34:18Z","receivedAt":"2011-07-05T21:34:18Z","isPatch":false,"sender":{"key":"driscoll@cs.wisc.edu","avatar":null},"body":"I have a somewhat unusual question. I often forget to push after committing,\nand a few times this has come back to bite me. (One time I didn't even really\nrealize for a couple months because I was working on other stuff, so\nunraveling the conflicts was \"fun\".)\n\nIs there a way I can get git to print a \"don't forget to push!\" reminder\nafter it commits?\n\nThe best way I can think of is to put a post-commit hook in there. I haven't\ntried it but I'd assume it would work, but would have to be on a\nper-repository basis instead of global.\n\n(I use git mostly for just my own projects, and almost always mostly in sort\nof a centralized setup: I've got one bare *the* repository that I clone, and\npush to and pull from that rather than between the copies. For a variety of\nreasons, I'm pretty sure that model wouldn't work super well for me.)\n\nThanks,\nEvan\n"},{"id":"170845","messageId":"4E138B65.5000500@gmx.de","threadId":"27758","inReplyTo":"loom.20110705T232905-603@post.gmane.org","subject":"Re: Getting git to help my memory","fromName":"Paul Ebermann","fromEmail":"paul-ebermann@gmx.de","sentAt":"2011-07-05T22:08:37Z","receivedAt":"2011-07-05T22:08:37Z","isPatch":false,"sender":{"key":"paul-ebermann@gmx.de","avatar":"https://gravatar.com/avatar/cc7e51a73ad3f42554d77240dde18357dc826227b021826a604ed4150e43c6f9?d=mp&s=160"},"body":"Evan Driscoll schrieb:\n> I have a somewhat unusual question. I often forget to push after committing,\n> and a few times this has come back to bite me. (One time I didn't even really\n> realize for a couple months because I was working on other stuff, so\n> unraveling the conflicts was \"fun\".)\n> \n> Is there a way I can get git to print a \"don't forget to push!\" reminder\n> after it commits?\n> \n> The best way I can think of is to put a post-commit hook in there. I haven't\n> tried it but I'd assume it would work, but would have to be on a\n> per-repository basis instead of global.\n\nYes, I just tried this. Here is the output (from adding a file in the test branch):\n\n---\n$ git commit \nDon't forget to push!\n[test ceabc34] adding test.txt.\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 test.txt\n---\n\nThe output is a bit hidden here. Maybe coloring would help here a bit.\n\n\nIs it really intentional that post-commit is called\n*before* the informational output here?\n\nI have no idea on how to automatically add the hooks to all\nthe repositories - AFAIK git clone will not copy these.\n\n\nPaŭlo\n"},{"id":"170849","messageId":"1309909855-sup-3456@pinkfloyd.chass.utoronto.ca","threadId":"27758","inReplyTo":"loom.20110705T232905-603@post.gmane.org","subject":"Re: Getting git to help my memory","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2011-07-05T23:52:53Z","receivedAt":"2011-07-05T23:52:53Z","isPatch":false,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"Excerpts from Evan Driscoll's message of Tue Jul 05 17:34:18 -0400 2011:\n\nHi Evan,\n\n> The best way I can think of is to put a post-commit hook in there. I\n> haven't tried it but I'd assume it would work, but would have to be\n> on a per-repository basis instead of global.\n\nI use this script as a post-commit hook in a few places...\n\n--snip--\n#!/bin/bash\n\necho -e \"\\e[32;01m\"\necho \"Don't forget to \\`git push\\` this...\"\necho -e \"\\e[0m\"\n--snip--\n\nHTH.\n-Ben\n--\nBen Walton\nSystems Programmer - CHASS\nUniversity of Toronto\nC:416.407.5610 | W:416.978.4302\n"},{"id":"170862","messageId":"vpqpqlnkfqv.fsf@bauges.imag.fr","threadId":"27758","inReplyTo":"loom.20110705T232905-603@post.gmane.org","subject":"Re: Getting git to help my memory","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2011-07-06T07:52:40Z","receivedAt":"2011-07-06T07:52:40Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Evan Driscoll <driscoll@cs.wisc.edu> writes:\n\n> I have a somewhat unusual question. I often forget to push after committing,\n> and a few times this has come back to bite me. (One time I didn't even really\n> realize for a couple months because I was working on other stuff, so\n> unraveling the conflicts was \"fun\".)\n\nI have a cron job that sends me a mail with the list of \"unpushed\"\nrepositaries on my account every nights (it also runs \"git fsck\", \"git\ngc\", and writes some .keep files to prevent \"git gc\" from repacking\nlarge packs and be friendly with backups and unison).\n\nIt's not really cleaned up, and may well work just for me, but in case\nyou're interested, the scripts are attached:\n\n* git-gc-fsck.sh is the script itself\n\n* git-foreach is a home-made git command to manage a set of unrelated\n  repositories. Essentially, one can\n\n  git foreach update   => run some \"find\" commands in your $HOME to find\n                          repositories.\n\n  git foreach do blah  => run command blah in each repository.\n\n\n\n#! /bin/sh\n\nstatus=0\nsubject=\"\"\nemail=Matthieu.Moy@imag.fr\nbody=/tmp/git-gc-fsck.$$\n\ndiff=$(git-foreach update)\n\nif [ \"$diff\" != \"\" ]; then\n    (\n\techo \"Git repository list changed:\"\n\techo \"$diff\"\n\techo\n    ) >> \"$body\"\n    subject=\"$subject change\"\nfi\n\nunpushed=$(git foreach --quiet do sh -c 'u=$(git rev-parse @{upstream} 2>/dev/null);\nif [ $? = 0 ]; then\n    graph=$(git log --graph --oneline $u..);\n    if [ \"$graph\" != \"\" ]; then\n        pwd\n        echo \"$graph\" | sed \"s/^/    /\"\n        echo\n    fi\n    graph=\"\"\nfi')\n\nif [ \"$unpushed\" != \"\" ]; then\n    (\n\techo \"Some Git repositories have unpushed content:\"\n\techo \"$unpushed\"\n\techo\n    ) >> \"$body\"\n    subject=\"$subject unpushed\"\nfi\n\nfailed_fsck=$(git-foreach do git fsck 2>&1)\nfsck_status=$?\n\necho \"$failed_fsck\"\n\nif [ \"$fsck_status\" != 0 ]; then\n    subject=\"FSCK $subject\"\n    status=1\n    (\n\techo \"Some Git repositories FAILED to fsck:\"\n\techo \"$failed_fsck\"\n\techo\n    ) >> \"$body\"\nelif git-foreach do git keep-pack --size +10M && \\\n    git-foreach do git gc > /dev/null; then\n    echo \"git gc succeeded\"\nelse\n    echo \"git gc failed, fsck succeeded. This is VERY strange ...\"\n    subject=\"GC $subject\"\n    status=1\nfi\n\nif [ \"$subject\" != \"\" ]; then\n    mail -s \"Git cron: $subject\" \"$email\" < \"$body\"\n    echo \"Email sent to $email : $subject\"\n    cat \"$body\"\n    rm -f \"$body\"\nfi\n\nexit \"$status\"\n\n\n\nBTW, if you really always want to push after commit, you can as well\nhave a post-commit-hook that does the push for you. But you lose part of\nthe power of Git by doing so (you can't rebase -i before pushing for\nexample).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}