Skip to main content

UCLA Git Walkthrough (for Moodle)

Very basic guide how to get GIT set up on Windows or OSX.

Documentation:

Setting up the Environment

Windows

Mac OSX

Install Git for OSX:

  • Standalone package:
    • Grab the latest git installer for your version of osx from Git for OSX
    • Run the contained pkg
    • If you want git to be accessible via the PATH and MANPATH variables for non-terminal programs, run the included shell script.
  • MacPorts:
    • sudo port install git-core

Generate an SSH Key:

Configure Line Endings

  • In order to avoid issues with line endings when cloning on to Windows machines, follow the directions here: Dealing with line endings

Setting up Git global configs

Before making commits, it is useful to add your name and email:

  • git config —global user.name “Your Name”
  • git config —global user.email “yourmail@domain.tld

If you want to connect to github without SSH you need a token:

Setting up your Github repository:

Once you’ve set up your repository on Github, you need to create a clone of the repository in each instance of Moodle you want running.

Clone the repository

  • With Github Token
  • With SSH RSA-key
    • git clone gitgithub.com:ucla/moodle.git ./YOUR_LOCAL_MOODLE_FOLDER/@

Now that you have a working clone of the repository in your working area, you can execute one of the following directives:

Set up your workflow

  • Execute the following commands:
    • git checkout master
    • git branch TESTdevelopment
    • git push origin TEST
    • git branch STAGE
    • git push origin STAGEdevelopment
  • This only needs to be done once. This will update the Github repository and all clones of your fork will now be able to pull these new branches from Github.

Work on a new features

  1. git checkout `git tag | grep "\-rc\$" | sort -r | head -1`
  2. git checkout -b feature/<feature_name>
  3. Repeat the following steps as necessary:
    • - change filesfile(s) -
    • git commit -a -m "CCLE-#### - A useful short comment summarizing what you did."
  4. git push origin <feature_name>
  5. This should be done whenever there is a new RC tag available:
    • git merge `git tag | grep "\-rc\$" | sort -r | head -1`
  6. Once the feature has passed code and administrative review:
    1. git checkout DEVdevelopment
    2. git merge --no-ff feature/<feature_name>
    3. git push origin development

Push a bug fix/hot fix

  1. git checkout `git tag | grep "\-gm\$" | sort -r | head -1`
  2. @git checkout -b
  3. - change file(s) -
  4. git commit -a -m "CCLE-#### - Description of bug fix."
  5. git push origin DEV

Bug Fixes

Get changes onto TEST

  1. git checkout TEST
  2. git merge --no-ff <feature_name>
  3. git push origin TEST

Get changes onto STAGE

  1. git checkout STAGE
  2. git merge --no-ff <feature_name>
  3. git push origin STAGE

Get changes onto master

  1. git checkout master
  2. git merge --no-ff <feature_name>
  3. git push origin master

Get changes onto SSC

  1. git checkout SSC
  2. git merge --no-ff <feature_name>
  3. git push origin SSC

Updating DEV from moodle.org

  • git checkout DEV
  • git remote add upstream https://github.com/moodle/moodle.git
  • git fetch upstream
  • git merge -m "upgrading Moodle to version X.Y" <commit_hash>
  • START RESOLVE CONFLICTS
  • git add <conflicted_file>
  • git add <conflicted_file>
  • git commit -m "upgrading Moodle to version X.Y"
  • DONE RESOLVE CONFLICTS
  • git push origin DEV