[HowTo] Maintain a remote fork for pull requests (TortoiseGIT)


You’re not seeing double, this guide is the same as the one that was pinned for over a year with over 5k views. It was recently merged into a topic about the GIT commandline which I personally feel was not the right place for it.

This guide is specifically for people who use TortoiseGIT and want to write patches. It’s easier to ask and answer questions in its own topic without the clutter of the commandline discussion, not to mention find it using the search tool.

Technically it belongs on the wiki but for now this will do.

The Guide:

TrinityCore uses pull requests instead of raw patches for submitting changes. This makes it easier for the devs. to review the code and talk to the patch creator (inline on github) before merging into the source.

The purpose of this guide is to help those who may not be familiar with the process. It will show you how to:

[ul][li]Create a remote fork[/li][li]Push a patch to your remote fork[/li][li]Create a pull request[/li][li]Keep your remote fork up-to-date with the main repo[/li][/ul]
This guide will cover the use of TortoiseGIT on Windows XP (should be similar for other Windows versions). All of the procedures can be done via the GIT commandline which I may write a tutorial for soon ™.


[li]An account on github.com[/li][li]TortoiseGIT[/li][li]Windows (I know, I know… eww!)[/li][li]A web browser[/li][/ul]
I. Fork the main repo

This provides you with a personal copy of the repo for submitting pull requests

[ul][li]1. Open your browser and go to the main TrinityCore repo[/li][li]2. Click the ‘create fork’ button[/li][/ul]
II. Clone the fork to your local PC

This will allow you to create branches and patches. We will refer to this as your ‘local repo’.

[ul][li]1. Open your browser to your fork you made in step I[/li][li]2. Click HTTP (or ssh if available) and copy the URL in the box[/li]As of 2013-11-01 Github has changed its layout. There is a “Clone URL” box on the right side of the page. Click either HTTPS or SSH to toggle between the two and copy the desired URL from the box
[li]3. Create a folder on your harddrive (give it a meaningful name)[/li][li]4. Right-click in the folder from step 3 and choose: ‘TortoiseGIT->Clone’[/li][li]5. Paste the URL you copied from step 2 into the ‘URL’ box and click ‘OK’[/li]III. Create a reference to the remote master

This will allow you to keep your fork up-to-date with the master

[ul][li]1. Right-click on your local repo and select ‘TortoiseGIT->Synch…’[/li][li]2. Click ‘Manage’ next to the ‘Remote URL’ box[/li][li]3. Fill in the remote info for the master you cloned:[/li]3a. Name: Anything you want
[li]3b. URL: The URL of the master you cloned from I.1[/li][li]3c. click ‘OK’[/li][/ul]
[li]4. Close the main dialog, we will use this reference later[/li]IV. Synchronizing the remote fork with the remote source

This synchronizes your remote fork with the remote TrinityCore master.
You should do this before starting a new branch / patch.

[ul][li]1. Switch your local repo to its master branch[/li]1a. Right-click on your local repo and select ‘TortoiseGIT->Switch/Checkout…’
[li]1b. Choose ‘master’ and click ‘OK’[/li][/ul]
[li]2. Right-click on your local repo and select ‘TortoiseGIT->Sync…’[/li][li]3. Make sure both ‘local branch’ and ‘remote branch’ say ‘master’[/li][li]4. Select the reference to the remote master you made in step III for ‘Remote URL’[/li][ul]* Choosing ‘origin’ here would just pull your fork again
[li]5. Click ‘Pull’[/li][li]6. Click ‘OK’[/li][li]7. Right-click on your local repo and select ‘TortoiseGIT → Push…’[/li][li]8. Make sure both ‘local branch’ and ‘remote branch’ say ‘master’[/li][li]9. Select ‘origin’ for ‘Remote URL’[/li][ul]* Origin should point to the fork you made in step I
[li]10. Click ‘OK’[/li]V. Creating a local branch

This allows you to keep track of the patches you’re working on.
You should synchronize your repo before starting (see step IV).

[ul][li]1. Right-click on your local repo and select ‘TortoiseGIT->Create Branch…’[/li][li]2. Give the branch a unique name[/li][li]3. Select which branch to base it on (usually master)[/li][li]4. Click ‘OK’[/li][li]* Optionally select “switch to branch” if you plan to work in it[/li][/ul]
VI. Creating a patch and pushing it

This allows you to push your patch to your remote fork, preparing for a pull request

Always synchronize (see step IV) with the TrinityCore master and create a new branch (see step V)
BEFORE starting a new patch

Please note, if you receive password prompts when trying to push to your repo, review the documents on
github regarding SSH Keys: Setup GIT (scroll down to ‘Set Up SSH Keys’) and SSH issues

[ul][li]1. Switch to the desired branch if not already in it:[/li]1a. Right-click on your local repo and select ‘TortoiseGIT->Switch/Checkout…’
[li]1b. Choose the branch and click ‘OK’[/li][/ul]
[li]2. Make your changes[/li][ul]Compile and test your patch


[li]3. Push the changes to the local repo (if everything compiled / tested OK)[/li][ul]3a. Right-click on your local repo and select ‘TortoiseGIT->Commit->’

  • This will show the name of the current branch
    [li]3b. Enter a comment and click ‘OK’[/li][ul]* If your patch closes an issue on Github, using the issue number with
    a ‘#’ should create a clickable link to the original issue when you push to your fork.
    [li]example: closes #5637[/li][/ul]

[li]4. Push the changes to the remote fork[/li][ul]4a. Right-click on your local repo and select ‘TortoiseGIT->Push…’
[li]4b. Fill in the information under the ‘Branch’ group[/li]Local: <select the branch you’re interested in>
[li]Remote: [/li][li]* This will force creation of the remote branch[/li][/ul]
[li]4c. Fill in the information under ‘Destination’[/li][ul]Remote: <select the remote you’re pushing to>
[li]* This should be your fork which is typically ‘origin’[/li][/ul]
[li]4d. Click ‘OK’[/li]
VII. Creating a pull request

This lets the developers know you’ve got some code to review
Always compile and test before submitting a pull request

[ul][li]1. Open your browser to your fork you made in step I[/li][li]2. Click the button that says ‘branch: master’[/li]* It may not say ‘master’ if you were browsing another branch
[li]3. Select the branch you just pushed in step VI[/li][li]4. Click the ‘pull request’ button (not the ‘pull requests’ button)[/li][li]5. Enter something descriptive and submit your request[/li]Final notes:

This may seem a bit daunting but after you’ve done it a few times it’s pretty simple. The most involved part is synchronizing your fork with TrinityCore because of the interim step of sucking it down to your harddrive first.

It is important to remember to:

[ul][li]Always synchronize with the TrinityCore master and create a new branch BEFORE[/li]starting a new patch.
[li]Always compile and test your patches before submitting a pull request[/li]
You can repeat steps IV to VII as often as you want. Just remember it is easier to work on each patch in a separate branch. That way you won’t contaminate your work with unrelated, unnecessary changes.

Finally, if you feel like it, you can delete your fork via github but make sure your pull request has been merged first or your changes will be lost.

Edit1: Clarify a few things and add links to Git for information on SSH (step VI).
Edit2: Added emphasis on compiling and testing
Edit3: Fix typo (spacing)
Edit4: More clarifications


I, for one, didn’t like the merge, I think each guide must be in a separate topic as long as they cover separate aspects of a problem.

Shouldn’t rebasing be a requirement as well before initiating a pull request?


Since a rebase simply pulls a fresh copy and attempts to merge your changes, it is redundant to what you did in the guide (pull a fresh copy before starting work). Once you submit your PR it could end up sitting for a long time before anyone attempts to merge it and it would most likely fail at that point anyway.

A rebase before pull request would only be useful if it were guaranteed that a developer would review and merge your changes within a timely fashion.

Can I do the same procedures using only git or git extensions? I mean, without TortoiseGIT installed (how?)

What about Github for Windows?

All these graphical interfaces run on top of Git. Everything can be done with Git alone.