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/
- Mac OSX: http://help.github.com/mac-set-up-git/
- Linux: http://help.github.com/linux-set-up-git/
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 "Your email address"
Set these git config settings
- @git config —global push.default current // only push current branch to remote@
git config --system core.ignorecase false // makes sure that git is case sensitive
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_USERNAME@github.com/ucla/moodle.git ./YOUR_LOCAL_MOODLE_FOLDER/
- With SSH RSA-key
- git clone git@github.com:ucla/moodle.git ./YOUR_LOCAL_MOODLE_FOLDER/
Set up your workflow
- ! You only need to do this if you are a lead developer and have not set up your GitHub repository. !
- 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/task
Name your git branch using our naming convention:
- type/jira ticket-short description
- The type, for now, should either be:
- feature (something that has never existed before or an improvement to a current feature)
- patch (a bug fix, can either come from internal or external sources)
- tests (For Behat or PHPunit only branches)
- update (reserved for core Moodle version and external plugin updates)
git checkout mastergit pull origin mastergit checkout -b feature/CCLE-<JIRA ticket number>-<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 -u origin <branch_name>- Merge task onto TEST
git checkout developmentgit pull origin developmentgit merge --no-ff <branch_name>git push origin development
Creating rc branches
git checkout mastergit checkout -b <release_number>-rc- Now merge in several branches with fixes/features that passed review
git merge --no-ff feature/<feature_name>git push -u origin <release_number>-rc
- 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 <release_number>-rc origin/<release_number>-rc- Once rc passes testing on TEST, merge it into master so it can go to stage
git checkout mastergit merge --no-ff <release_number>-rc -m "Description of what was in this release/use JIRA version description"-
git push origin master-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 "Description of what was in this release/use JIRA version description"- The numbers M.m.v.rr should be the same as the numbers for the RC branch.
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 — Note: This no longer is needed, you should be able to cleanly expedite the regular workflow for urgent fixes.
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
git checkout -b update/M.m.vgit remote add core https://github.com/moodle/moodle.gitgit fetch core-
git merge -Xtheirs -m "CCLE-<ticket> - Upgrade Moodle to version X.Y" <version tag>(hopefully there will be a JIRA ticket relating to this. - Resolve conflicts
git add <conflicted_file>- If needed, continue the merge
- Finish the pull.
- 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
- To upgrade to a major release of Moodle, follow the instructions in this guide: http://tjhunt.blogspot.com/2014/01/moving-ou-moodle-code-to-moodle-261.html