Git
Git is a version control system. It handles projects as repositories (often called repo) with a history. The history consists of commits. A commit is a change to the code with the description.
Git allows people to create forks of a repo. A fork is a new repo with the same history and content, but when commiting to the fork, the main repo is not affected. This allows developers to work on projects without access to the main repo.
To bring other peoples work into the main repo, they can open a pull request. This can easily be done in the GUI of GitHub.
Git also has the ability to create branches in one repository. This allows developers to work on multiple features at the same time.
Minetest has two repositories: The engine is in the "minetest" repo and the main game is in the "minetest_game" repo. The repositories are hosted on GitHub.
Use Git to get the latest updates
You can use Git to get the latest updates of Minetest in a RUN_IN_PLACE version. To do this, clone the main repo:
# Get the engine
git clone git://github.com/minetest/minetest.git #Creates a directory called "minetest" with all the content
# Get minetest_game
cd minetest/games/
git clone git://github.com/minetest/minetest_game.git #Creates a directory called "minetest_game" with all the content
To get the latest updates of the engine (you have to compile Minetest after this) do this in the cloned minetest directory:
git pull
To get the latest updates of minetest_game:
cd games/minetest_game/
git pull
Use Git for development
Creating a Fork
(Note: In this example only the engine repository is used, but you can do the same with the minetest_game repo):
To use Git for development you have to fork the main repository on GitHub first. After this you can clone your repo:
git clone git://github.com/Your_user_name_on_GitHub/minetest.git #Creates a directory called "minetest" with all the content
cd minetest/
Coding a feature
Create a new branch to code your feature (be sure to give them good names (not just "patch" or "fix")):
git checkout -b feature_branch
Now you can code your feature. If you are done you have to commit your feature and push it to your repo on GitHub:
git add . # Adds all changes; alternatively you can specify single files
git commit -m "Your feature"
git push origin feature_branch
Commit messages should start with a capital letter and use the present tense. They should sum up the feature/fix.
You can now acces your code in your repository on GitHub and open a pull request for it to the main repo.
To go back to your master branch do:
git checkout master
If you have to update your feature do:
git checkout feature_branch
# Do changes
git add .
git commit -m "Update message"
git push origin feature_branch
This will automatically be added to the pull request (if there one).
Update your fork
You can use GIT to update your Minetest fork with the latest changes of the offical repository.
Prerequisites
If you haven't already you need to tell git where to get the changes.
git remote add upstream git://github.com/minetest/minetest
cd games/minetest_game
git remote add upstream git://github.com/minetest/minetest_game
Updating the Fork
You need to download the changes of the main repo first and then merge them. For the Engine:
# Get the changes
git fetch upstream
# Merge the Changes
git merge upstream/master
# Push the result to github
git push
For the Game:
cd games/minetest_game
# Get the changes
git fetch upstream
# Merge the changes
git merge upstream/master
# Push the result to github
git push