Member-only story
How to automate Github using Cron?
Leverage crontab utility for running sequence of Github commands regularly.
Use Case : Keeping my fork* updated with the upstream*
Technology used : Bash Scripting, Git, SSH, Cron
Initial setup
cd /home/ubuntu
mkdir src && cd src/
git clone --recursive git@github.com:ChaiBapchya/incubator-mxnet.git
Note : Use ssh link instead of https for git clone


In order to automate git commands using bash script, we should use SSH over HTTPS. Using SSH is a safer way of providing authentication & permissions to perform git commands.
Setup SSH keys on Github account & machine
First, generate a new SSH key [pair of public and private keys]
Verify the SSH key is correct
$ ssh -T git@github.com
Hi ChaiBapchya! You’ve successfully authenticated, but GitHub does not provide shell access.
Copy the public key
$ cat ~/src/id_rsa.pub
Upload it to Github account following steps mentioned here.
For my use-case, I want to sync my fork & rebase the feature branch.
In order to sync with the upstream, I have to add the upstream repository once. Moreover, to update the feature-branch I need to fetch it once. The name of my feature branch is update_gpu_toolchain
cd incubator-mxnet/
git remote add upstream https://github.com/apache/incubator-mxnet
git fetch origin
git checkout --track origin/update_gpu_toolchain
cd ..
Bash Script
vi cron_rebase_gpu.sh