• Using Git and GitHub for Garry's Mod Dedicated Servers
    15 replies, posted
I've recently been experimenting quite a bit with git and Garry's Mod since it makes the entire workflow of Dev Server==>Push==>Public Server. Let's look at a method for accomplishing our goal. Download Github Desktop and have a GitHub account. Create a repository for your server. Make a .gitignore that will ignore Gmod core files, the data folder, and sv.db. You want to ignore the data/sv.db since you don't want to override your public server's data and you ignore the core files since they're way too large --> a dedicated server update would take years. Now you'll make a remote version (public server), and you'll download the Gmod dedicated server into that remote folder with steamcmd. Pull your GitHub repository into the remote folder, and you're done. When you push your new updates, you'll want to pull them to your remote server. If you want this done automatically, set something up with webhooks or a cron job, perhaps. This will certainly work with websites other than GitHub, but I prefer GitHub since it has the most comprehensive array of features available. See how it goes, have fun with it, and post your results down below. Happy committing!
Don't use GitHub desktop, download git bash and learn how to use git on the command line.
Git repos have hooks of their own that make this a breeze.
Oh I'd really like to set something like this up for my personal use, but I don't know how I'd make it work. Interested to see what others have to say
Thanks for the little heads-up! I'm sure this will give some inspiration to server developers on GMod that have not yet branched out towards more complex situations. Sure this is common knowledge in regular software development, but for GMod this article is new and I think your hint will help (at least some) people get some proper DevOps in place on their servers.
Absolutely use github desktop until you're familiar with the concepts of git, then perhaps start learning the command line. Github desktop is fenomenal and I still prefer it over command line on day-to-day work because it's just so much more user friendly.
I'd recommend basically any other graphical git client over both, but I have not tried using Github Desktop in several years so things may have changed.
You really only need to use three commands when first starting out.. git add * git commit -m "" git push There's no excuse of it being too complicated besides learning the command line. But for that all you need to know is the basic file structure of your machine and 'cd'.
That's true but the gui is a lot more user friendly still. It gives you the kind of feedback that makes sense to a new user. Seeing the history of commits, not having to deal with staging, etc. Github desktop has abstracted git away on a perfect level imo. Its becoming better by the day so if you haven't tried it in a few years I'd definitely recommend it. I've taught a lot of my friends git and they all definitely found the gui a lot better than the command line.
look, i'm smart, i cant stand other people using tools that eases tasks
He's just shown you that you don't need to be smart
FTFY
GitHub Desktop is not the old GitHub for Windows. That being said, GitHub desktop it still largely meant to be used with GitHub and has its problems, but you can use it with other repos ( I had to manually set this up via git bash ) Still, you'd want to use a GUI app over command line especially if you are a beginner. For me a GUI program allows to sanity check my changes much more easily, and as stated above you can see commit history, etc.
I use GitHub desktop too, but can also use the bash. Before I used GitHub I used GitLab because of the free private repos. Now I am a student at GitHub so I can use private repos for free. So I highly recomend GitHub Desktop, but it is not wrong to learn it. In a (good) company you are not even able to use GitHub Desktop, and Git for companies is god.
For a short while now private Github repo's have been free for anyone, yay!
Adding to this thread since I actually am using git push-to-deploy configurations. Sorry if I'm necroing On your server: (this assumes you are using a Linux with git installed): (this also assumes that your .gitignore has default gmod server folders added to it) user@server:~$ git clone git@github.com:Username/RepoName myserver user@server:~$ cd myserver user@server:~/myserver$ steamcmd steamcmd> login anonymous steamcmd> force_install_dir /home/user/myserver steamcmd> app_update 4020 validate steamcmd> ^C user@server:~/myserver$ nano .git/hooks/post-receive then type in this (change paths to your specific paths): #!/usr/bin/env bash read oldrev newrev ref echo "Updating $oldrev -> $newrev ($ref)" git --work-tree=/home/user/myserver--git-dir=/home/user/myserver/.git checkout -f then user@server:~/myserver$ chmod +x .git/hooks/post-receive On your PC (assumes you have git CLI installed): ~$ cd /path/to/repo /path/to/repo$ git remote add production user@127.0.0.1:/home/user/myserver You now have a remote called "production" pointing to localhost. Change 127.0.0.1 to your server's IP and the absolute path to your server. IT MUST BE ABSOLUTE. I also recommend adding a hostname to your SSH config for easier time deploying: (and I also recommend using SSH keys instead of plaintext passwords since they're more secure and easier in general operation) ~/.ssh/config: Host myserver Hostname 127.0.0.1 User user # only put this in if you are using ssh keys, ignore this if you are using plaintext passwords IdentityFile ~/.ssh/id_rsa Lets make some commits /path/to/repo$ git add . /path/to/repo$ git commit -m "I did some important changes!" # push to origin (github/gitlab/somethingelse) /path/to/repo$ git push # deploy to production /path/to/repo$ git push production master And you're done, the changes should be on the server at this point and all that remains is to restart it (which you can also make the bash script in post-receive do). Hope this comes in handy. I got tired of people using FTP and giving their FTP details to their "trusted developers", who in turn upload backdoors and do stupid stuff, so I keep telling my friends to just use git, since it provides free version control and nobody uploads anything to your server without it being in the commits history (provided they don't have direct ssh).
Sorry, you need to Log In to post a reply to this thread.