Note: You are currently viewing documentation for Moodle 3.7. Up-to-date documentation for the latest stable version of Moodle may be available here: Git for developers.

Development:Git for developers: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
Line 1: Line 1:
This document are for purpose to make you start super quickly (in the hour) with GIT. It doesn't have for purpose to explain you GIT. Please have a look to the real
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... (TODO)


1. Go on [https://github.com/ Github] and create a account.
1. Go to [https://github.com/ Github] and create an account.


2. Go on https://github.com/moodle/moodle and click on Fork button. You now have your github repository.
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] install it in few click.
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 repository from your local repository. On mac you get go on this [http://help.github.com/mac-key-setup/ Github help page]. If you are on another system, in the Github administration, section SSH Public Keys, you should see a link to a help page. Is it done? Good, it was some difficult.
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.


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


6. Now you are going to create update script in order to update your cvshead. For that first we need to edit the file .git/config that is in YOUR_LOCAL_MOODLE_FOLDER. Create something like this:
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:


<code bash>
<code bash>
Line 36: Line 36:
</code>
</code>


7. Create a update script (example: ./update_github)
7. Create the update script (name it "update_github")


<code bash>
<code bash>
Line 48: Line 48:
8. Run the./update_github script. Your local repository ("cvshead" branch) and your github repository ("cvshead" branch) will be updated from git.moodle.org.
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:
9. Now when you want to work on a new issue. The (not detailled) process is the following:
* run the update script (take care to have stach/committed the change of current branch)
* 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
* create a new branch
* fix the bug
* fix your issue with your favorite IDE.
* commit, push and do a pull request.
* commit, push and do a pull request.

Revision as of 04:03, 14 December 2010

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... (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/*

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.