Reputation:
Usually when I push to a git repo I get output like this
$ git push origin somefeature
Counting objects: 42, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (42/42), done.
Writing objects: 100% (42/42), 13.39 MiB | 2.69 MiB/s, done.
Total 42 (delta 5), reused 0 (delta 0)
To github.com:greggman/someproject.git
* [new branch] somefeature -> somefeature
But, sometime in the few months when I push to github I see these remote:
messages.
$ git push origin somefeature
Counting objects: 42, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (42/42), done.
Writing objects: 100% (42/42), 13.39 MiB | 2.69 MiB/s, done.
Total 42 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
remote:
remote: Create a pull request for 'somefeature' on GitHub by visiting:
remote: https://github.com/greggman/someproject/pull/new/somefeature
remote:
To github.com:greggman/someproject.git
* [new branch] somefeature -> somefeature
How do I accomplish this with my own git repos? Like for example
remote: Hello World
To put it another way, say I setup a public repo that you ssh to at ssh://freerepos.com
. You type
git clone ssh://freerepos.com/some/repo.git
then make some changes, commit them, and type
git push origin master
How do I configure my repo so it prints
remote: Hello World
in your terminal when you push to my machine the same way github is currently inserting remote output when I push to their machines?
Upvotes: 1
Views: 837
Reputation: 7563
This is done using server-side git hooks.
Both standard output and standard error output are forwarded to git send-pack on the other end, so you can simply echo messages for the user.
Upvotes: 3
Reputation:
adding a post-update
hook does this
cat > .git/hooks/post-update
#!/bin/sh
echo "hello world"
results in
$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 245 bytes | 245.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: hello world
To /Users/me/temp/delme-git/pub-repo
deae6fa..4d3d769 master -> master
Upvotes: 0