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:
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/@
-
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`— this will checkout the latest RC tag 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
Creating rc branches
git checkout <latest_gm_tag>git checkout -b rc<rc_num>- Now merge in several branches with fixes/features that passed review
git merge --no-ff feature/<feature_name>git push origin rc<rc_num>
- If one or more branches failed testing, then create another rc branch with the number incremented merge in the fixes/branches that work
-Start- TEST machine ONLY
At this point, there could be more than one feature that is being tested!
git checkout -b rc<rc_num> origin/rc<rc_num>- Once rc passes testing on TEST, merge it into development so it can go to stage
-
git checkout mastergit merge --no-ff rc<rc_num>
-End- On TEST machine ONLY
-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 checkout mastergit pull origin master-
git tag M.m.v.rr-gm -m "CCLE-####: Description (and more as needed)"- 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!
-End- On PROD machine ONLY
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 (or merge the branch directly)
git tag M.m.v.rr-hf -m "CCLE-####: Description of bug fix."git push origin M.m.v.rr-hf
- Push it to STAGE
git checkout mastergit merge --no-ff M.m.v.rr-hfgit 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-gm -m "CCLE-####: Description of bug fix."git push origin M.m.v.rr-gm
- Update the PROD machine
git fetchgit checkout `git tag | grep "\-gm\$" | sort -r | head -1`
- We need to back-push our hot-fix into our development tract
git checkout developmentgit merge --no-ff M.m.v.rr-hfgit push origin development
- Each feature branch can merge the back-pushed tag if desired.
Pulling from a version from Moodle.org
- Decide to pull up as a hot-fix or as a feature
- As a hot-fix:
git checkout `git tag | grep "\-gm\$" | sort -r | head -1`
- As a feature:
git checkout `git tag | grep "\-rc\$" | sort -r | head -1`
- As a hot-fix:
git checkout -b merge/M.m.vgit remote add upstream https://github.com/moodle/moodle.gitgit fetch upstream-
git merge -m "Upgrading Moodle to version X.Y" <commit_hash>(hopefully there will be a JIRA ticket relating to this. - Resolve conflicts
git add <conflicted_file>git commit -m "upgrading Moodle to version X.Y"- If needed, continue the merge
- Finish the pull up as a hot-fix or a feature.
- As a hotfix:
- Test and push to STAGE, release on PROD, then back push to development.
- As a feature:
- Push to development, test on TEST, push to STAGE then release on PROD.
- Be sure to notate the new RC and GM tags with the updated Moodle version M.m.v.00
- As a hotfix: