Frank Ralf (talk | contribs) |
Frank Ralf (talk | contribs) |
||
(41 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Setting up a remote repository on | == Cloning Moodle to your local installation == | ||
* See [[Git for Administrators]], the following screenshots illustrate the steps described there. | |||
[[File:Git cloning Moodle.png]] | |||
=== Cloning to a new folder === | |||
[[File:Git cloning Moodle new folder.png]] | |||
=== Moodle branches === | |||
[[File:Git remote Moodle branches.png]] | |||
=== Checkout === | |||
[[File:Git checkout MOODLE 19 STABLE.png]] | |||
== Deleting master branch == | |||
Don't know whether this is a good idea but I accidentally messed up my local Moodle 1.9 master branch by fetching Moodle 2.1 on top of it ... | |||
* See the discussion in the Moodle General Developer Forum: [http://moodle.org/mod/forum/discuss.php?d=181720 Git: deleting local "master" branch] | |||
=== Moodle 1.9 === | |||
[[File:Git delete master branch.png]] | |||
That's the result: | |||
[[File:Git only local branch left.png]] | |||
=== Moodle 2.0 === | |||
[[File:Git delete local master branch 2.0.png]] | |||
== Updating your Moodle installation == | |||
<code php>git fetch</code> | |||
[[File:Git fetch.png| thumb | First try ...]] | |||
[[File:Git branch fetch 2011-07-20.png| thumb |Second try ...]] | |||
Following the [[User:Sam_Hemelryk/My_Moodle_Git_workflow| instructions by Sam Hemelryk]]: | |||
=== Moodle 1.9 === | |||
==== fetch ==== | |||
[[File:Git fetch status 2011-07-20.png]] | |||
==== merge ==== | |||
[[File:Git merge 2011-07-20.png]] | |||
=== Moodle 2.0 === | |||
==== fetch ==== | |||
[[File:Git fetch Moodle 2.0.png]] | |||
==== merge ==== | |||
git merge origin/MOODLE_20_STABLE | |||
[[File:Git merge Moodle 2.0 2011-07-22.png]] | |||
'''Note''': Updating these 500 files took only about 10 seconds! | |||
== Maintaining your own contributed code == | |||
=== Copying the plug-in code to your Moodle installation === | |||
[[File:Git adding my custom plugin code.png]] | |||
=== Making Git ignore your code === | |||
Put the folder names for your own code into the '''.git/info/exclude''' file in your Moodle clone, as the following excerpt from .gitignore describes. On Windows the .git folder is hidden by default so you will have to change your settings to show hidden files (Explorer > Tools > Folder settings ...). | |||
# Example: if you deploy a contributed plugin mod/foobar into your site, put | |||
# the following line into .git/info/exclude file in your Moodle clone: | |||
# /mod/foobar/ | |||
That's how it looks: | |||
# git ls-files --others --exclude-from=.git/info/exclude | |||
# Lines that start with '#' are comments. | |||
# For a project mostly in C, the following would be a good set of | |||
# exclude patterns (uncomment them if you want to use them): | |||
# *.[oa] | |||
# *~ | |||
/blocks/firephp | |||
/filter/autolinkhijacker | |||
=== Setting up a remote repository on GitHub === | |||
See the instructions at: | See the instructions at: | ||
Line 5: | Line 88: | ||
* [[Git repositories for contrib modules]] | * [[Git repositories for contrib modules]] | ||
== Cloning the remote | === Cloning the remote GitHub repository to your local Moodle installation === | ||
# Change to the parent folder for your plug-in | # Change to the parent folder for your plug-in | ||
# Clone the repository: <code>git clone https://nakohdo@ | # Clone the repository: <code bash>git clone https://nakohdo@GitHub.com/nakohdo/moodle-filter_autolinkhijacker.git</code> | ||
# Rename the folder to your plug-in's name | # Rename the folder to your plug-in's name | ||
# Open Git Bash in that folder | # Open Git Bash in that folder | ||
== Creating a local branch == | === Creating a local branch === | ||
# Open Git Bash in the plug-in folder | # Open Git Bash in the plug-in folder | ||
Line 19: | Line 102: | ||
#* Both steps in one: <code bash>git checkout -b MOODLE_19_STABLE</code> | #* Both steps in one: <code bash>git checkout -b MOODLE_19_STABLE</code> | ||
== Creating a remote branch == | === Creating a remote branch === | ||
{{Note| | |||
It might be better using "remote" first to create the remote branch. | |||
And usually it's best if both branches have the same name. | |||
--[[User:Frank Ralf|Frank Ralf]] 12:59, 18 July 2011 (WST) | |||
}} | |||
# Change to the correct local branch | # Change to the correct local branch | ||
# <code bash>git push origin -u MOODLE_19_STABLE</code> | # <code bash>git push origin -u MOODLE_19_STABLE</code> | ||
#: Using different names for local and remote branch: <code bash>$ git push origin local_19_STABLE:MOODLE_19_STABLE </code> | |||
[[File:Git creating remote branch.png | 600px]] | [[File:Git creating remote branch.png | 600px]] | ||
=== Deleting a remote branch === | |||
$ git push origin :testbranch | |||
http://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-both-locally-and-in-github | |||
== Git GUI (aka GitTk) == | |||
For launching the command line commands from a GUI. This will automatically be installed together with "Git for Windows" and is equally accessible from the explorer context menu. | |||
[[File:Git Gui (moodle).png]] | |||
=== Visualize branch history === | |||
[[File:Gitk moodle 2011-07-20.png]] | |||
== See also == | == See also == | ||
* [[User:Sam Hemelryk/My Moodle Git workflow]] | |||
; Moodle forum discussions | ; Moodle forum discussions | ||
* [http://moodle.org/mod/forum/discuss.php?d=168094 GIT help needed] | * [http://moodle.org/mod/forum/discuss.php?d=168094 GIT help needed] | ||
Line 37: | Line 142: | ||
* [http://gitref.org/ Git Reference] | * [http://gitref.org/ Git Reference] | ||
* [http://progit.org/book/ Pro Git book] | * [http://progit.org/book/ Pro Git book] | ||
; Stackoverflow resources | |||
* [http://stackoverflow.com/questions/1427785/how-to-set-desired-language-in-git-gui How to set desired language in git-gui?] | |||
* [http://stackoverflow.com/questions/3841140/git-how-to-get-rid-of-the-annoying-crlf-message-on-msysgit-windows GIT: How to get rid of the annoying CRLF message on msysgit (windows)?] | |||
* [http://stackoverflow.com/questions/6414515/how-to-do-rebase-interactive-in-a-windows-gui How to do rebase --interactive in a Windows GUI?] | |||
[[Category:Git]] | [[Category:Git]] | ||
[[Category:Developer]] |
Latest revision as of 12:05, 15 August 2011
Cloning Moodle to your local installation
- See Git for Administrators, the following screenshots illustrate the steps described there.
Cloning to a new folder
Moodle branches
Checkout
Deleting master branch
Don't know whether this is a good idea but I accidentally messed up my local Moodle 1.9 master branch by fetching Moodle 2.1 on top of it ...
- See the discussion in the Moodle General Developer Forum: Git: deleting local "master" branch
Moodle 1.9
That's the result:
Moodle 2.0
Updating your Moodle installation
git fetch
Following the Sam Hemelryk/My Moodle Git workflow:
Moodle 1.9
fetch
merge
Moodle 2.0
fetch
merge
git merge origin/MOODLE_20_STABLE
Note: Updating these 500 files took only about 10 seconds!
Maintaining your own contributed code
Copying the plug-in code to your Moodle installation
Making Git ignore your code
Put the folder names for your own code into the .git/info/exclude file in your Moodle clone, as the following excerpt from .gitignore describes. On Windows the .git folder is hidden by default so you will have to change your settings to show hidden files (Explorer > Tools > Folder settings ...).
# Example: if you deploy a contributed plugin mod/foobar into your site, put # the following line into .git/info/exclude file in your Moodle clone: # /mod/foobar/
That's how it looks:
# git ls-files --others --exclude-from=.git/info/exclude # Lines that start with '#' are comments. # For a project mostly in C, the following would be a good set of # exclude patterns (uncomment them if you want to use them): # *.[oa] # *~ /blocks/firephp /filter/autolinkhijacker
Setting up a remote repository on GitHub
See the instructions at:
Cloning the remote GitHub repository to your local Moodle installation
- Change to the parent folder for your plug-in
- Clone the repository:
git clone https://nakohdo@GitHub.com/nakohdo/moodle-filter_autolinkhijacker.git
- Rename the folder to your plug-in's name
- Open Git Bash in that folder
Creating a local branch
- Open Git Bash in the plug-in folder
- Create new branch:
git branch MOODLE_19_STABLE
- Change to the new branch:
git checkout MOODLE_19_STABLE
- Both steps in one:
git checkout -b MOODLE_19_STABLE
- Both steps in one:
Creating a remote branch
Note: It might be better using "remote" first to create the remote branch. And usually it's best if both branches have the same name. --Frank Ralf 12:59, 18 July 2011 (WST)
- Change to the correct local branch
git push origin -u MOODLE_19_STABLE
- Using different names for local and remote branch:
$ git push origin local_19_STABLE:MOODLE_19_STABLE
- Using different names for local and remote branch:
Deleting a remote branch
$ git push origin :testbranch
http://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-both-locally-and-in-github
Git GUI (aka GitTk)
For launching the command line commands from a GUI. This will automatically be installed together with "Git for Windows" and is equally accessible from the explorer context menu.
Visualize branch history
See also
- Moodle forum discussions
- GIT help needed
- Best way to manage CONTRIB code with GIT
- Handy Git tip for tracking 3rd-party modules and plugins
- Moodle Git repositories
- External resources
- Stackoverflow resources