UCLA Git Walkthrough (for Moodle)
Very basic guide how to get GIT set up on Windows or OSX.
Documentation:
Setting up the Environment
Windows
- http://help.github.com/win-set-up-git/
- 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:
- Follow the directions here: Mac Key Setup
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:
- Follow the directions here: Email and Github Tokens
Setting up your Github repository:
- Go to https://github.com/moodle/moodle
- Click “Fork”
- Got to Admin→Collaborators→Add (add any number of collaborators to the project)
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
-
git clone https://YOUR_GITHUB_USERNAMEgithub.com/ucla/moodle.git ./YOUR_LOCAL_MOODLE_FOLDER/@
-
- 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 mastergit branch developmentgit push origin development
- 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 feature
git checkout `git tag | grep "\-rc\$" | sort -r | head -1`git checkout -b feature/<feature_name>- Repeat the following steps as necessary:
- change file(s) -git commit -a -m "CCLE-#### - A useful short comment summarizing what you did."
git push origin <feature_name>- This should be done whenever there is a new RC tag available:
git merge `git tag | grep "\-rc\$" | sort -r | head -1`
*Once the feature has passed code and administrative review *
git checkout developmentgit merge --no-ff feature/<feature_name>git push origin development
*Start On TEST machine ONLY *
- At this point, there could be more than one feature that is being tested! *
-
git pull origin development
*End On TEST machine ONLY *
*Once the feature(s) has been successfully tested and passed *
- @git tag M.m.v.rr-rc @
- M.m.v.rr-rc is [Moodle Major Version].[Moodle Minor Version].[Moodle Incremental Version].[Internal Version]-rc, where ‘rc’ stands for ‘release candiate’.
- @git push origin M.m.v.rr-rc @
- @git checkout master @
- @git merge —no-ff M.m.v.rr-rc @
- @git push origin master @
*Start On STAGE machine ONLY *
-
git pull origin master
*End On STAGE machine ONLY *
*Once the feature(s) has been successfully test on STAGE and is ready for PROD *
-
git tag M.m.v.rr-gm- The numbers M.m.v.rr should be the same as the numbers for the RC tag.
git push origin M.m.v.rr-gm
Start On PROD machine ONLY
git fetchgit checkout `git tag | grep "\-gm\$" | sort -r | head -1`- Validate things are working…
- Finished with release cycle!
Push a bug fix/hot fix
git checkout `git tag | grep "\-gm\$" | sort -r | head -1`- @git checkout
b bugfix/CCLE#### @ - Repeat until you have the bug fixed in your working instance:
- change file(s) -git commit -a -m "CCLE-#### - Description of bug fix."
- Once the bug has passed code and administrative review you can make a HF tag and push it to STAGE:
git tag M.m.v.rr-hfgit push origin M.m.v.rr-hfgit checkout master- @git merge —no-ff M.m.v.rr-hf @
git push origin master- Update the STAGE machine
git pull origin master
- Once tested on STAGE, make a GM tag.
git tag M.m.v.rr-gmgit push origin M.m.v.rr-gm- Update the PROD machine
git fetchgit checkout `git tag | grep "\-gm\$" | sort -r | head -1`
- Once a GM tag has been released, then we need to back-push our hot-fix into our development tract
git checkout development- @git merge —no-ff M.m.v.rr-hf @
git push origin development
- Each feature branch can merge the HF tag if desired.
Updating DEV from moodle.org
git checkout DEVgit remote add upstream https://github.com/moodle/moodle.gitgit fetch upstreamgit 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