Git Wrangling

Welcome! Ok so this is a first post on this recently cleaned out blog, so lets get right into it.

I am wanting to do some development on the CanaryMod Server for Minecraft, specifically on the current Crow build. To get that however, I had to get the damn thing down off Git. So obviously, the first place you head when your new to something is the tutorials. These do really help actually, and gave me a basic idea of how to get things going, and how similar the Git command line stuff is to Linux (which isn’t much of a surprise as its based on Linux, and actually uses a Linux shell emulator even in Windows to get things done). Anyway, this is how I eventually got my fork of CanaryMod out of the cloud!

First, fork the original CanaryMod Git repository, using the web based interface. Just go to the main page, and on the top right, click fork. Git will do the rest on that side, and then you’l have your own fork of CanaryMod under your own username.

So next, you need to go to the Git command line interface. On windows, this is called Git Bash. In Linux, I have no idea, although its probably just called Git and you just call it on the command line without any other problems.

In the Bash prompt, go to the directory you want to pull the repo in to. Mine is called ‘workspace’, as im going to be running Eclipse straight on top of it. Then activate the git repo for this folder with:

git init

So that Git will then create the database it needs for the repo.

This next bit had me stumped for a bit until I googled for it. I wanted to fork JUST the crow branch, not the master branch (as the master branch hasn’t been updated for a while). I could find the usual control to clone a Git repo, which is:

git clone git@github.com:username/repo.git

Where username is your username, and repo is the repository name. (in this case, TBSliver and CanaryMod, respectively). This would clone just the main or master branch. To clone the crow branch, you need an extra command, as below:

git clone -b crow git@github.com:TBSliver/CanaryMod.git

This would then clone just the crow branch. Obviously, putting this into your Git line will not work, as you don’t have my password or RSA key or whatever it was I set up when I started it.

So with just that, you have the CanaryMod Crow branch on your computer! Of course this is not very useful on its own, apart from just compiling it (which will have another post dedicated to getting it into Eclipse and running from there). You’l need to commit new changes! Also, what happens if new things happen on the original branch? Read on!

So If you looked through the tutorial for Git, you’l remember something about adding an upstream repo. This allows you to pull any updates done to the original repo you forked form, into your local repo ready to merge. So if you now go into the CanaryMod folder (cd CanaryMod) you can run this to track it:

git remote add upstream git://github.com/shadow386/CanaryMod.git

git fetch upstream

This adds the git repo with an alias of upstream, and then fetches it. You can then merge this with your branch with the following command:

git merge upstream/crow

There is always more that you can do with Git, and I’m only just learning how to use it. Anyone find any errors, please let me know and i’l update this!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.