Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listening for Git Repo Changes

Tags:

git

push

I want to write an app that given a user's GitHub account information and a repo will be notified whenever the repo is pushed to. I know I could basically save the state of the repo and poll it for changes periodically but I was wondering if there is a way to do this with a push architecture and if so how to go about it. Thanks for any help!

EDIT - I know I can probably doing this like Heroku does it by having them push to a remote server, but the ideal functionality is to know when they push to Github itself.

like image 774
dshipper Avatar asked Jun 21 '11 19:06

dshipper


People also ask

How do you retrieve changes from a remote repo?

Fetching changes from a remote repositoryUse git fetch to retrieve new work done by other people. Fetching from a repository grabs all the new remote-tracking branches and tags without merging those changes into your own branches. Otherwise, you can always add a new remote and then fetch.

Which command is used to check in the changes into repository?

The git status command is used to examine the current state of the repository and can be used to confirm a git add promotion.

Do git hooks get pushed?

No. Hooks are per-repository and are never pushed.


2 Answers

If you want to perform an action when a push is received, you can write a script and use it as a post-receive hook. GitHub supports git-hooks, but for obvious reasons they do not allow you to write a "custom script". What their script do is actually simple - they notify you by POSTing a JSON to an URL you specify. See their documentation.

like image 189
jweyrich Avatar answered Sep 29 '22 12:09

jweyrich


One way which:

  • wouldn't involve the main contributor of a repo to enter anything
  • would allow you to define what you want to monitor

is to use:

  • 2011 (since discontinued) Yahoo Pipe services (and then write an app getting the result of said pipes), like the Friend Stalker pipes described by nefariousdesign.
  • 2020 alternatives like GitHub Actions, and, for instance:
    • racket/email-notifications
    • other notifications and messages actions
like image 27
VonC Avatar answered Sep 29 '22 12:09

VonC