How to update files in my computer whenever they get updated in github?

1k views Asked by At

I know this might sound stupid but I couldn't find a solution on the Internet.
I'm working on a project in GitHub and every time someone adds a new file or some new code I have to download the whole files on my computer in order to open them from my local host.

As you can imagine this is really tiring and I know there are easier ways to update the files.
Could anyone please propose an alternative solution?

1

There are 1 answers

0
VonC On

The normal workflow is simply to do a git pull on demand (assuming those files are pushed on the same branch as the one you are working on).

That means, whenever you are ready, you make a git pull and get the updated files that way.
It is a pull workflow, not a push (from GitHub) workflow.

That being said, if you need a local repository with always the latest files updated (again, from a specific branch), you would setup a GitHub webhook whic, on each push, would notify a listener on your machine, triggering from that listener a git pull.

See this gist for an example, executed from an local web server in php.
A more complete example here.

You can use any language to setup a listener/server on your machine, which will be contacted by GitHub.
See "Webhook to auto-deploy on git push to Github " as a detailed example, using a web server in Go.