Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Git for developers: Difference between revisions

From MoodleDocs
m (Protected "Git for developers": Developer Docs Migration ([Edit=Allow only administrators] (indefinite)))
 
(176 intermediate revisions by 38 users not shown)
Line 1: Line 1:
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)
{{Template:Migrated|newDocId=/docs/guides/git/}}
 
== The set up ==
 
1. Go to [https://github.com/ Github] and create an account.
 
2. Go to the [https://github.com/moodle/moodle 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, [http://code.google.com/p/git-osx-installer/ 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 [http://help.github.com/mac-key-setup/ 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.
 
== Working on 2.0 ==
 
1. Create a local clone repository of your github repository. In a terminal:
<code bash>
git clone git@github.com:YOUR_GITHUB_USERNAME/moodle.git ./YOUR_LOCAL_MOODLE_FOLDER/
</code>
 
2. 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:
 
<code bash>
 
[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/*
 
</code>
 
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.
 
3. Create the update script (name it "update_github")
 
<code bash>
cd YOUR_LOCAL_MOODLE_FOLDER
git fetch upstream
git checkout cvshead
git pull
git push origin refs/remotes/upstream/cvshead:cvshead
</code>
 
4. Run the./update_github script. Your local repository ("cvshead" branch) and your github repository ("cvshead" branch) will be updated from git.moodle.org.
 
5. 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.
 
== Working on 1.9 or earlier branches ==
This is just a little bit more complicated that working on 2.0. Please read the previous chapter before executing this one. You are going to create a new folder for working in 1.9. Actually you could work in the same folder that 2.0, but it will make thing a bit more messy and less easy to understand.
 
1. In a terminal
<code bash>
git clone git@github.com:YOUR_GITHUB_USERNAME/moodle.git ./YOUR_LOCAL_MOODLE_19_FOLDER/
</code>
 
2. Now you are going to create a local 1.9 branch. You will keep this branch updated and you are never going to work in it. First we create this MOODLE_19_STABLE branch
<code bash>
git checkout -b MOODLE_19_STABLE origin/MOODLE_19_STABLE
</code>
 
3. Add the remote upstream. You want it to update your local MOODLE_19_STABLE branch and your github (called "origin") MOODLE_19_STABLE branch.
<code bash>
git remote add upstream git://git.moodle.org/moodle.git
</code>
 
4. Create the update script in ./update_github
<code bash>
cd /Users/jerome/Documents/Projects/Moodle_Git_PHPStorm/Moodle_19
git fetch upstream
git checkout MOODLE_19_STABLE
git pull
git push origin refs/remotes/upstream/MOODLE_19_STABLE:MOODLE_19_STABLE
</code>

Latest revision as of 12:14, 14 April 2023

Important:

This content of this page has been updated and migrated to the new Moodle Developer Resources. The information contained on the page should no longer be seen up-to-date.

Why not view this page on the new site and help us to migrate more content to the new site!