Using -tg-station in Git as a submodule

How, what and why to code in BYOND.
Post Reply
nullquery
Joined: Sun Nov 09, 2014 8:51 pm
Byond Username: NullQuery

Using -tg-station in Git as a submodule

Post by nullquery » #98869

Hi,

I'm using -tg-station in Git as a submodule, and I thought I'd post the how-to here.

What is this about?

My repository now looks like this:

Image

The "tgstation" folder is a link to the nullstation/-tg-station repository. This is my own fork of /tg/ rather than /tg/ directly as I want more control of merging, but you can point directly to the main /tg/ repository if you want to.

Pros:
  • I don't need to worry about upstream. Clicking on the folder just links to the nullstation/-tg-station repository and is not a subfolder in the nullstation/nullstation repository. This means I can merge without having to resolve conflicts in the /tg/ code; instead I only need to resolve the conflicts in my own code (which I've written myself, so it's significantly easier to fix things).
  • The nullstation/nullstation repository is not a forked repository but is standalone. This means I can search through the code in Github, which isn't possible when dealing with forked repositories.
  • I can still merge at my own discretion. The "@ 0d3eda5" after the folder name points to the commit that the folder is based on. The "tgstation" folder is synced independently from the main project folder.
  • I don't share the commit history of the /tg/station project, so all I can see is my own commits. But if I want to look at the commit history of /tg/station all I need to do is click on the "tgstation" folder and it'll take me to my -tg-station fork, where I can see the commit history.
Cons:
  • I can't modify any resources in the "tgstation" folder without pushing my changes to nullstation/-tg-station, and respectively pushing it upstream back to the main -tg-station repository. But this is what I want. I'm going to push changes toward /tg/ that allow me to make my own modifications without requiring me to merge things or do conflict resolution, which benefits everyone.
But how does that work with the .dme?

At the top of your .dme file you write an include line to include the -tg-station source-code. On top of that you compile your own stuff. In an empty .dme it would look like this:

Code: Select all

#include "tgstation/tgstation.dme"
// BEGIN_INTERNALS
// END_INTERNALS
// BEGIN_FILE_DIR
#define FILE_DIR .
// END_FILE_DIR
// BEGIN_PREFERENCES
// END_PREFERENCES
// BEGIN_INCLUDE
// END_INCLUDE
So how can I do this?

Simple, just follow these instructions:
  • Create a new repository.
  • Use TortoiseGit or your other favorite program to clone the repository and perform an initial commit. It doesn't really matter what you commit, so long as the repository is properly initialized.
  • Now we need to get to a bash terminal. On Windows you can do this by right-clicking the root folder and clicking "Git Bash". This will open a bash prompt in the root folder.
  • Copy the following command: "git submodule add git://github.com/nullstation/-tg-station.git tgstation" and replace "nullstation/-tg-station" with your own fork (or -tg-station directly if you don't plan to work on /tg/ directly). This will create the folder.
  • Now you can commit as usual. The commit window will show you're adding a folder called "tgstation". It won't mention any of the files within the folder (as it's a link). Just add it and you're done!
But how do I update?

If you do a git pull (or push) on the root folder you'll pull (or push) from/to your own repository. If you do a git pull (or push) on the "tgstation" folder you'll pull (or push) from/to the -tg-station repository.

In Windows this works seamlessly by right-clicking the appropriate folder.

Screenshots:

Image Image

The result

Check it out: https://github.com/nullstation/nullstation

Questions?

I'll be available for any questions you may have, feel free to reply to this thread and I'll get to them within a day. :)
Post Reply

Who is online

Users browsing this forum: No registered users