Difference between revisions of "User:Frank Ralf/Git"

Jump to: navigation, search

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

(Deleting master branch)
(Deleting master branch)
Line 16: Line 16:
 
== Deleting master branch ==
 
== 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 ...
 
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]
+
* 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 ===
 
=== Moodle 1.9 ===

Revision as of 15:34, 22 July 2011

Cloning Moodle to your local installation

Git cloning Moodle.png

Cloning to a new folder

Git cloning Moodle new folder.png

Moodle branches

Git remote Moodle branches.png


Checkout

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 ...

Moodle 1.9

Git delete master branch.png

That's the result:

Git only local branch left.png

Moodle 2.0

Git delete local master branch 2.0.png

Updating your Moodle installation

git fetch
First try ...
Second try ...

Following the instructions by Sam Hemelryk:

fetch

Git fetch status 2011-07-20.png

merge

Git merge 2011-07-20.png

Maintaining your own contributed code

Copying the plug-in code to your Moodle installation

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:

# 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

  1. Change to the parent folder for your plug-in
  2. Clone the repository:
    git clone https://nakohdo@GitHub.com/nakohdo/moodle-filter_autolinkhijacker.git
  3. Rename the folder to your plug-in's name
  4. Open Git Bash in that folder

Creating a local branch

  1. Open Git Bash in the plug-in folder
  2. Create new branch:
    git branch MOODLE_19_STABLE
  3. Change to the new branch:
    git checkout MOODLE_19_STABLE
    • Both steps in one:
      git checkout -b MOODLE_19_STABLE

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)

  1. Change to the correct local branch
  2. git push origin -u MOODLE_19_STABLE
    Using different names for local and remote branch:
    $ git push origin  local_19_STABLE:MOODLE_19_STABLE

Git creating remote branch.png

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.

Git Gui (moodle).png

Visualize branch history

Gitk moodle 2011-07-20.png

See also

Moodle forum discussions
External resources
Stackoverflow resources