2 Using Git with Mapbase
Blixibon edited this page 2020-12-09 23:08:43 -06:00

Mapbase's code was specifically designed to be merged into forks of Source 2013 by using Git. This lets you merge Mapbase into an existing mod or update an existing mod already running on Mapbase quickly and easily.

Setting up Git

This tutorial was originally written by Xenthio. (todo: Clarify stuff, explain how to fix an incompatible repo, etc.)

Download Git:

  • Windows - Download and install Git for Windows.
  • Mac - type git in terminal, if git isn't installed already, it will prompt you to install it. Git can also be installed with Homebrew.
  • Linux - If it isn't installed already, install Git using your distro's Package Manager.

It may be beneficial to use a GUI for Git as well, like TortoiseGit or Sourcetree, but this tutorial will use command line instructions.

Forking the Mapbase repository

The Mapbase repository on GitHub can be forked by clicking here.

Once you've set up a repo on GitHub, open up the terminal or command prompt of your choice. Type cd followed by the directory of your choice. (EXAMPLE: cd "E:\My Mapbase Fork")

Type git clone <REPO-LINK>

This clones the repo to your computer. (EXAMPLE: git clone https://github.com/xenthio/source-sdk-2013)

A new folder will be created using the name of the repository (normally source-sdk-2013) in the directory you navigated to with cd. It will contain a local copy of the repository on GitHub.

Committing and Pushing Changes

Whenever you make a change, you should commit and push (upload) the change to the GitHub repo.

Do this by navigating to your repo's directory in the command line and typing:

git add path/to/file.txt

Adds the file to the commit, do git add . to add all changed files.

git commit -m "Change Message"

Commits the files, the message can be anything, e.g "Cleaned up code" or "Squashed some bugs", makes it easy to tell which commit changed what.

git push

Upload all commits you just made to the repo.

Merging Mapbase updates

When ever a Mapbase update is released, you can merge the changes into your repo. Make sure you've pushed all local commits before doing this.

Head over to the terminal, navigate to your repo's directory and type:

git fetch upstream

Gets all commits from the Mapbase master branch into a temporary branch.

git checkout master

Goes back to the normal master branch of your repo.

git merge upstream/master

Merges the master branch with the Mapbase master branch.