Norman Lancaster
Member
In this post I will outline the steps required to use GitHub and the git command line tools to create a custom code base for your shard that can be kept up to date with the ServUO codebase as it is updated and allows you to contribute back any bug fixes or feature additions at the same time.
Initial Setup and Workflow for Shard-Specific Features
If you wish to resolve a defect or contribute a feature to the ServUO codebase, please do so! This project would not be where it is without the involvement of its community. When you identify such a contribution, please use the following workflow.
After a pull request has been merged into the ServUO master the branch containing the commits is no longer needed. Here are the steps for cleaning up old branches.
Thanks!
Initial Setup and Workflow for Shard-Specific Features
- If you do not have an account at https://github.com/ go create that now.
- Now go to the ServUO project page (currently at https://github.com/ServUO/ServUO/)
- Click on the "Fork" button. This will create a fork of the ServUO project under your user account.
- Rules about the fork:
- Never commit to master! The master branch of your fork will track the remote upstream master (ServUO/ServUO) and will be where we pull changes from upstream. It is very important that you never make your own changes to the master branch.
- Always branch from master unless you really know what you are doing. This means that before you create any branch in the GitHub interface, the master branch should be selected and displayed in the branch drop-down.
- Now create a branch for your shard. As of the time of this writing this is done by opening the branch drop-down and typing in the new name of the branch. Name it something descriptive, like "Ponies Forever Shard".
- If you do not have the git software installed, do so now.
- For Windows systems, go here: https://git-scm.com/download/win
- For Linux systems, use your package manager
- For Debian-based systems the command is usually "sudo apt-get install git"
- Navigate to a location on your local file system where you would like ServUO to live.
- On Linux systems do this in a shell
- On Windows do this in an Explorer shell, then right-click in the folder and select "Git Bash Here"
- On the main GitHub page of your fork will be a URL ending in .git. Copy that URL.
- In the shell execute the command "git clone [the-url]"
- This will create a new directory named ServUO
- Execute the command "cd ServUO" to enter it
- Execute the command "git remote add upstream https://github.com/ServUO/ServUO.git"
- This is the configuration needed to update from upstream master later on
- Important! Execute the command "git checkout [shard branch]" where [shard branch] is whatever you named the branch to contain your shard-specific code.
- If the branch name contains spaces replace them with dashes "-"
- This makes it so that all code changes you make are contained within the shard branch and do not touch master
- Write code here that is not intended to be pushed to the upstream repository. Things like changing the current expansion and setting the data path are good examples.
- Every time you have a tested, working change, commit and push them.
- Execute the command "git status" to see all modified files and ensure that it makes sense
- Use the command "git add [the-file]" to add the modified files to the commit
- Use the command "git commit" to commit the changes to the repository history
- Use the command "git push" to push the repository history changes to GitHub
- Follow the above steps for installing git and cloning the repository on the remote server
- Execute the command "git checkout [shard branch]"
- Now all of the code is exactly like it was on your development machine when you pushed it. Just start the server!
- Enter the ServUO directory with your shell or Git Bash Here command
- Execute the command "git fetch upstream"
- This will pull in the entire upstream repository into a local branch named upstream/master
- Execute the command "git checkout master"
- Execute the command "git merge upstream/master"
- So long as you never made any changes while on your own master this will be a fast-forward merge and you will not have to do anything special
- Execute the command "git push" to update your remote repository with the new upstream code
- Execute the command "git checkout [shard branch]"
- Execute the command "git merge master"
- This is where the pain happens. If you have modified something on your shard that ServUO has also modified (I'm talking the same line of the same file) then you will get something called a merge conflict.
- Resolving merge conflicts is too large a topic for this post. Please refer to this fine article: https://help.github.com/articles/resolving-a-merge-conflict-from-the-command-line/
- After the merge is complete, either with no conflicts or after all conflicts have been resolved and committed, execute the command "git push"
If you wish to resolve a defect or contribute a feature to the ServUO codebase, please do so! This project would not be where it is without the involvement of its community. When you identify such a contribution, please use the following workflow.
- Create a new branch on GitHub.
- Again, make sure the master branch is selected before you create the new branch
- Name the new branch something descriptive, like "Fix Mysticism Resist Mechanics" or "Resolve Issue 143"
- This new branch will be referred to as the feature branch.
- Enter the ServUO directory with your shell or Git Bash Here command
- Execute the command "git fetch"
- Execute the command "git checkout [feature branch]"
- Write code that is intended to be pushed to ServUO and commit it every time you have a working, tested solution.
- Use the same commit steps from above
- Note that you will be coding against stock ServUO, not your shard's codebase. This is important because the patch needs to work with all servers, not just yours.
- When the patch is ready to go to ServUO for testing and merge, open a pull request on GitHub
- Refer to this document regarding GitHub's UI: https://help.github.com/articles/creating-a-pull-request/
- Important! On the screen that lets you write comments for the pull request it also lists the commits contained within the pull request. Review this list and ensure that only the commits you want are included.
- Send the pull request off and it will be reviewed by a core team developer.
- I would recommend that you wait for the ServUO team to accept the pull request and let it enter your server's codebase that way. But for the impatient, you can do the following to merge it into your shard's code:
- "git checkout [shard branch]"
- "git merge [feature branch]"
- "git push"
After a pull request has been merged into the ServUO master the branch containing the commits is no longer needed. Here are the steps for cleaning up old branches.
- Delete the branch on GitHub by following these steps: https://github.com/blog/1377-create-and-delete-branches
- Enter the ServUO directory with your shell or Git Bash Here command
- Execute the command "git fetch -p"
Thanks!