tModLoader How to create a symlink between your github repository and mod sources

Jofairden

Duke Fishron
tModLoader
How to create a symlink between your github repository and mod sources [Windows]

Hello fellow Terrarians,
Today I'm going to show you how to ''sync'' your mod folder directly with your github repository folder.
What does this mean? If you have installed the Github desktop app, like most people, you will have a new folder \Documents\GitHub\ which will house repositories for you by default.
Of course you can sync from any location, but I'm going to show you how to do it from this location.

What are the benefits?
Your code is in one place and you don't have to copy & paste all over the place.

Let's get started!
First of all, what do you need to know? This trick makes use of a symlink (which by the way, is not limited to windows). We're going to use our command prompt to set it up. I'm sure people on another OS can modify to make it work for them.

The first thing you're going to need is a repository on GitHub. Go ahaid and create one if you don't have one already.
Now that you have your repository, go ahaid and open it in your GitHub desktop app, and make sure it's synced.
Due to the nature of how Visual Studio wants to make projects, we're going to delete this repository in just a moment.
Go into your repository folder and copy & paste these files/folders to a safe location: .gitattributes, .gitignore, .git (folder)
The .git folder may or may not exist, if you cannot see it: go to 'View' and make sure 'hidden items' is checked
2016-10-05 12_16_24-C__Users_Admin_Documents_My Games_Terraria_ModLoader_Mod Sources.png
Now delete this folder/repository (not from GitHub, just your computer in \Documents\GitHub\)

In visual studio, create your project. In the searchbox, you can just search for 'blank' and it should show a blank solution option.
Make sure 'create directory for solution' is checked, the location should be \Documents\GitHub and the name of the solution is the internal name of your mod.
2016-10-05 12_03_52-New Project.png


When the project is created, copy back your earlier copied files and folders. You should now be able to relocate the repository in GitHub desktop.

Now let's get to the trick
( thanks to shockah, suggested you can also use a symlink gui tool to more easily create symlinks https://github.com/amd989/Symlinker , although I sincerely think you should be able to handle command prompt just fine )

A symlink can link certain locations. We're going to link a folder in Mod Sources to our Github repository folder.
To do this, we need to open up command prompt with admin privileges.
Go ahaid and press WINDOWS KEY + R and type cmd and press enter or hit OK.
To create a symlink, we use this command:
Code:
mklink /J "Path/To/Mod Sources/MyMod" "Path/To/Github/MyMod"
It is important that no folder with your mod name exists yet in your Mod Sources folder
So in your terminal, type this command. Replace the locations with your paths. For example, I used this for this tutorial:
Code:
mklink /J "C:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\TutorialMod" "C:\Users\Admin\Documents\GitHub\TutorialMod"
Make sure you accompany paths with " because they usually have spaces in them!
Now your mklink should result in:
Junction created for C:\Users\Admin\Documents\My Games\Terraria\ModLoader\Mod Sources\TutorialMod <<===>> C:\Users\Admin\Documents\GitHub\TutorialMod

You should now have a symlink appearing in your Mod Sources folder!
2016-10-05 12_20_35-GitHub.png

This means your code is in one place and the moment you have edited your mod you can immediately commit to your github repository.
Have fun!

( I did not use git shell or anything. because I doubt most people know how it works, github desktop is simple but effective )
 
Last edited:
Back
Top Bottom