I'm also curious as how to do this :O
Sorry for not replying earlier, I've been busy.
I followed
this tutorial as a base for my automated pushing system. Looking back on this, I must have changed something because I swear I had it set up to automatically push to GitHub (as you can see from the mess that is my
commit history).
Anyways, basically you have a bare repo (called Hub in the tutorial) and a normal repo (called Prime in the tutorial). In the repo folder (or in the
.git folder within the repo folder, if it's not a bare repo) there is a folder named
hooks. You'll want to edit the files accordingly:
(note, all of this is assuming you're running the server on Linux. I don't know to do these things in Windows)
post-update in Hub:
#!/bin/bash
echo
echo "**** Pulling changes into UDodge Prime [UDodge Hub's post-update hook]" # this is optional, it just echos (prints to the command line) whenever it updates Prime
echo
cd $HOME/gmodds/garrysmod/addons/udodge || exit # update the path to the location of your Prime repo
unset GIT_DIR
git pull hub master # make sure you have set up the 'hub' remote in Prime to point to the Hub repo, otherwise this won't work
exec git update-server-info
post-commit in Prime:
#!/bin/bash
echo
echo "**** Pushing changes to UDodge Hub [UDodge Prime's post-commit hook]" # again, optional
echo
git push hub # make sure you have that remote set
To extend this so it actually does what I said it would, you could set it up to push to GitHub whenever anything is changed. This would involve adding to each of the files, probably right under the echos to make sure the changing directories doesn't mess up anything. Again, make sure you have a remote called 'origin' set to the GitHub repo.
In the end I really didn't like this workflow because I would end up committing errors. When I could normally just rebase and gloss over those mistakes, with this workflow I can't do that without force pushing (which is dangerous). I'm not sure what a better workflow would be. I guess running a local server would be ideal because then you could test changes locally before pushing, but that comes with all the limitations of not having a dedicated server. Another possibility would be to push to the server, test the changes, and then push to GitHub. But at that point you may as well just use FTP to transfer the files and then create the commits on the server itself.