Kaggle Github Sync using Shell Script

  1. Create a Github repository
  2. Run “git init” on the local folder
  3. Run “git remote add origin https://github.com/user/repo.git” on the local folder
  4. Create a file shell.sh with the below code on the local folder
  5. Run “bash shell.sh” on the local folder

Shell.sh

for item in $(kaggle kernels list --user USERNAME); do
        if [[ $item == *"USERNAME"* ]]; then
                toreplace=""
                kaggle kernels pull $item -p "${item/USERNAME\/$toreplace}"
        fi
done;
git add .;
git commit -m 'update';
git push -u origin master;

Run Manually

Run “bash shell.sh” on the local folder whenever you make changes to your Kaggle kernels

Crontab

Use crontab to automatically run the script hourly, daily, weekly or monthly

Unable to connect to github.com

Example Code to run

Git config global URL from git://github.com to https://github.com

git config --global url.https://github.com/.insteadOf git://github.com/

This replaces git: to https:

Solution to Issues such as

bower install stops with error : fatal: unable to connect to github.com

Git : Revert back to Previous Revision

Revert back to Previous version in git

Required

  • Get the REVISIONNUMBER ( Revision number ) of the previous Revision which you want the files to revert back to.

Here is how you could revert back to previous Revision in git

  1. git reset –hard REVISIONNUMBER
  2. git push –force

Caution

This will delete all yours commits made between the REVISIONNUMBER and the CURRENT Revisionnumber