I have a somewhat unusual question. I often forget to push after committing,
and a few times this has come back to bite me. (One time I didn't even really
realize for a couple months because I was working on other stuff, so
unraveling the conflicts was "fun".)
Is there a way I can get git to print a "don't forget to push!" reminder
after it commits?
The best way I can think of is to put a post-commit hook in there. I haven't
tried it but I'd assume it would work, but would have to be on a
per-repository basis instead of global.
(I use git mostly for just my own projects, and almost always mostly in sort
of a centralized setup: I've got one bare *the* repository that I clone, and
push to and pull from that rather than between the copies. For a variety of
reasons, I'm pretty sure that model wouldn't work super well for me.)
Thanks,
Evan
From: Paul Ebermann <hidden> Date: 2016-06-15 22:51:32
Evan Driscoll schrieb:
I have a somewhat unusual question. I often forget to push after committing,
and a few times this has come back to bite me. (One time I didn't even really
realize for a couple months because I was working on other stuff, so
unraveling the conflicts was "fun".)
Is there a way I can get git to print a "don't forget to push!" reminder
after it commits?
The best way I can think of is to put a post-commit hook in there. I haven't
tried it but I'd assume it would work, but would have to be on a
per-repository basis instead of global.
Yes, I just tried this. Here is the output (from adding a file in the test branch):
---
$ git commit
Don't forget to push!
[test ceabc34] adding test.txt.
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 test.txt
---
The output is a bit hidden here. Maybe coloring would help here a bit.
Is it really intentional that post-commit is called
*before* the informational output here?
I have no idea on how to automatically add the hooks to all
the repositories - AFAIK git clone will not copy these.
Paŭlo
From: Ben Walton <hidden> Date: 2016-06-15 22:51:32
Excerpts from Evan Driscoll's message of Tue Jul 05 17:34:18 -0400 2011:
Hi Evan,
The best way I can think of is to put a post-commit hook in there. I
haven't tried it but I'd assume it would work, but would have to be
on a per-repository basis instead of global.
I use this script as a post-commit hook in a few places...
--snip--
#!/bin/bash
echo -e "\e[32;01m"
echo "Don't forget to \`git push\` this..."
echo -e "\e[0m"
--snip--
HTH.
-Ben
--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302