{"id":13587550,"url":"https://github.com/kolbasa/git-repo-watcher","last_synced_at":"2025-08-18T11:42:02.276Z","repository":{"id":40523770,"uuid":"80649615","full_name":"kolbasa/git-repo-watcher","owner":"kolbasa","description":"A simple bash script to watch a git repository and pull upstream changes if needed.","archived":false,"fork":false,"pushed_at":"2023-01-16T17:52:04.000Z","size":41,"stargazers_count":178,"open_issues_count":0,"forks_count":37,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-06T06:41:07.545Z","etag":null,"topics":["bash","daemon","fetcher","git","github","interval","notify","pull","remote","repo","repository","shell","sync","synchronizer","up-to-date","updater","upstream","watch","watcher","windows"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kolbasa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-01T18:20:51.000Z","updated_at":"2024-10-25T16:45:38.000Z","dependencies_parsed_at":"2023-02-10T05:16:24.311Z","dependency_job_id":null,"html_url":"https://github.com/kolbasa/git-repo-watcher","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbasa%2Fgit-repo-watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbasa%2Fgit-repo-watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbasa%2Fgit-repo-watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbasa%2Fgit-repo-watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kolbasa","download_url":"https://codeload.github.com/kolbasa/git-repo-watcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236579775,"owners_count":19172029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","daemon","fetcher","git","github","interval","notify","pull","remote","repo","repository","shell","sync","synchronizer","up-to-date","updater","upstream","watch","watcher","windows"],"created_at":"2024-08-01T15:06:15.731Z","updated_at":"2025-01-31T20:31:01.664Z","avatar_url":"https://github.com/kolbasa.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# Git Repo Watcher\n\nA simple bash script to watch a git repository and pull upstream changes if available.\n\n### Requirements\n\n* Bash with Version \u003e 3\n* Tested on Ubuntu, Debian, MacOS, [Windows Git Shell](https://git-scm.com/download/win), [Windows Subsystem for Linux (WSL)](https://www.microsoft.com/en-us/p/ubuntu/9nblggh4msv6)\n\nBasically, it will work anywhere you can install Bash.\n\nIf something doesn't work, please [let me know](https://github.com/kolbasa/git-repo-watcher/issues).\n\n### Usage\n\nYou only need the path to your git repository to start.  \nMake sure your local repository is tracking a remote branch, otherwise the script will fail.\n\nThis will start a watcher that looks for changes every 10 seconds:\n```bash\n./git-repo-watcher -d \"/path/to/your/repository\"\n```\n\nThe time interval can be changed by passing it to `-i` (seconds):\n```bash\n./git-repo-watcher -d \"/path/to/your/repository\" -i 60\n```\n\nYou can also turn off the watcher by passing `-o`.  \nThis will execute the script only once.\n```bash\n./git-repo-watcher -d \"/path/to/your/repository\" -o\n```\n\n### Customizations\n\nYou can add your own logic to the file: [`git-repo-watcher-hooks`](https://github.com/kolbasa/git-repo-watcher/blob/master/git-repo-watcher-hooks)\n\nFor example, you can start your build process in case of changes:\n\n```bash\n# $1 - Git repository name\n# $2 - Branch name\n# $3 - Commit details\nchange_pulled() {\n    echo \"Starting build for commit: $@\"\n    ./your-build-script.sh\n}\n```\n\nIf you have more than one repository you can pass a copy of the `git-repo-watcher-hooks` file like so:\n```bash\n./git-repo-watcher -d \"/path/to/your/repository\" -h \"/path/to/your/hooks-file\"\n```\n\n### Private repositories\n\nThe script works with private repositories.  \n\nFirst configure a password cache with `git config --global credential.helper \"cache --timeout=60\"`.  \nMake sure the `timeout` is greater than the time interval given to the script. Both are given as seconds.  \nThe program will execute `git fetch` and ask for your login data. The script itself **does not** store passwords!\n\nIf you want it to run in the background as a daemon process, you have to execute `git fetch` beforehand.\n\nExample code:\n\n```bash\ncd \"/path/to/your/repository\"\ngit config --global credential.helper \"cache --timeout=60\"\ngit fetch\n\n# Checking exit code\nif [[ $? -eq 1 ]]; then\n    echo \"Wrong password!\" \u003e\u00262\n    exit 1\nfi\n\n# Disown process\n./git-repo-watcher -d \"/path/to/your/repository\" \u003e \"/path/to/your/logfile.log\" \u0026 disown\n```\n\n### Windows 10\n\nThe easiest way is to install [Git Shell](https://git-scm.com/download/win), which also comes with bash.  \nThe only thing you have to consider are the file separators. The Unix format should be used here:\n\n`C:\\YourGitRepository` \u0026#8594; `/C/YourGitRepository`\n\nIt is a little more difficult with [WSL](https://www.microsoft.com/en-us/p/ubuntu/9nblggh4msv6).  \nThis must first be installed and configured via the Windows Store.\nThe file structure is also slightly different:\n\n`C:\\YourGitRepository` \u0026#8594; `/mnt/c/YourGitRepository`\n\n### Tests\n\nThe test suite [`git-repo-watcher-tests`](https://github.com/kolbasa/git-repo-watcher/blob/master/git-repo-watcher-tests) is using the test framework [shunit2](https://github.com/kward/shunit2), it will be downloaded automatically to your `/tmp` folder.  \nThe script has no other dependencies and requires no internet connection.\n\nThe tests create several test git repositories in the folder: `/tmp/git-repo-watcher`.\n\nA git user should be configured, otherwise the tests will fail.  \nWith the following line you can check if this is the case:\n```bash\ngit config --list\n```\n\nYou can configure it as follows:\n```bash\ngit config --global user.email \"your@email.com\"\ngit config --global user.name \"Your Name\"\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkolbasa%2Fgit-repo-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkolbasa%2Fgit-repo-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkolbasa%2Fgit-repo-watcher/lists"}