I have a GitHub repository for my dotfiles here.
It contains an installdotfiles.sh script to install the dotfiles from GitHub. I would like to have another git repository on GitLab for backup (and the really cool custom syntax-highlighting :P), mirroring this repository, except running the shell command on the repository:
grep -rl raw.githubusercontent . |
xargs sed -i ''
's/raw.githubusercontent/gitlab/g'; grep -rl 'dotfiles/master' . |
xargs sed -i '' 's/dotfiles\/master/dotfiles\/raw\/master/g'
which replaces the links to Github with the corresponding links to GitLab.
Basically, if I push to my GitHub dotfiles repository, I would my GitLab repository to automatically update, except run the script on the repository first, so I have my GitLab repository contains the GitLab links.
How would I implement such a hook?
I have heard that this can be implemented using Git Hooks, however I am unfamiliar with them, and reading about them, I don't exactly understand how such a thing would be done.
P.S it would be nice if it works both ways - so when I push to GitLab, GitHub will run a different script that replaces GitLab links with GitHub links, so that whenever I push to one, both update accordingly.