Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Git for developers.

Development:Git for developers

From MoodleDocs
Revision as of 05:30, 14 December 2010 by jerome mouneyrac (talk | contribs)

This document has for purpose to make you start quickly (in the hour) Moodle development with GIT. It doesn't have for purpose to explain you GIT. Please have a look to the full documentation for a better understanding of GIT... (TODO)

1. Go to Github and create an account.

2. Go to the official Moodle Github repository and click on the Fork button. You now have your own github Moodle repository.

3. Install GIT on your computer. If you are on Mac, git-osx-installer installs it in few click.

4. Now the technical part, you will need to setup your SSH public key, so you can push to your github Moodle repository from your local Moodle repository. On mac you can go on this Github help page. If you are on another system, go to the Github administration, to the section SSH Public Keys, and you should see a link to a help page. Is it done? Good, it was the most difficult.

5. Create a local clone repository of your github repository. In a terminal: git clone git@github.com:YOUR_GITHUB_USERNAME/moodle.git ./YOUR_LOCAL_MOODLE_FOLDER/

6. You will create a update script in order to update your github and local repository from git.moodle.org. First edit the file .git/config in YOUR_LOCAL_MOODLE_FOLDER. Modify for something like this:

[core]

       repositoryformatversion = 0
       filemode = true
       bare = false
       logallrefupdates = true
       ignorecase = true

[remote "origin"]

       fetch = +refs/heads/*:refs/remotes/origin/*
       url = git@github.com:YOUR_GITHUB_USERNAME/moodle.git

[branch "cvshead"]

       remote = upstream
       merge = refs/heads/cvshead

[remote "upstream"]

   url = git://git.moodle.org/moodle.git
   fetch = +refs/heads/*:refs/remotes/upstream/*

Note: you could have done it with a "git remote add" command, but I though it was important for you to know this settings file.

7. Create the update script (name it "update_github")

cd YOUR_LOCAL_MOODLE_FOLDER git fetch upstream git checkout cvshead git pull git push origin refs/remotes/upstream/cvshead:cvshead

8. Run the./update_github script. Your local repository ("cvshead" branch) and your github repository ("cvshead" branch) will be updated from git.moodle.org.

9. Now when you want to work on a new issue. The (not detailled) process is the following:

  • run the update script (the script will switch to "cvshead" branch, so take care to stach/commit the changes of your current branch)
  • create a new branch
  • fix your issue with your favorite IDE.
  • commit, push and do a pull request.