Skip to main content

Git Walkthrough

This is a first draft, very basic guide how to get GIT setup on windows or osx, and commit code to TEST.

Documentation:

Setting up the Environment

Windows

Install msysgit

Run Git from the Windows Command Prompt

  • checkout as-is, commit unix-style line endings

Install tortoise

  • OpenSSH, git default ssh client

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 connect to github without ssh you might need a token:

Setting up github repository:

Execute the following commands:

  • git branch TEST
  • git push origin TEST
  • git branch STAGE
  • git push origin STAGE
  • git branch SSC
  • git push origin SSC

New Features

  1. git clone https://YOUR_GITHUB_USERNAME@github.com/ucla/moodle.git ./YOUR_LOCAL_MOODLE_FOLDER/
  2. git checkout DEV
  3. git checkout -b <feature_name>
  4. change file
  5. git commit -a -m "updating README.txt to include basic git instructions"
  6. git push origin <feature_name>
    (Repeat above 3 steps as needed)
  7. git rebase origin/DEV
  8. git checkout DEV
  9. git merge --squashno-ff <feature_name>
  10. git commit -m <message>
  11. git push origin DEV

Bug Fixes

Get changes onto TEST

    1. git checkout TEST
    2. git cherry-pickmerge e9cb5
    3. --no-ff
    4. git cherry-pick d40dc
    5. Repeat as necessary to get all the changes
    6. git pull origin TEST<feature_name>
    7. 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