Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: instructions for fixing work committed to local master


  1. Make sure you have git setup and have a github account and have your name and email properly set as git global variables on your workstation.
  2. Fork the central Sakai repository to your own github account
    1. We will use the following references
      1. local = local git clone on your workstation, this where everyone typically does their work
      2. origin = this is your local fork of the sakai project on github, you clone this repo on your local workstation
      3. upstream = this is main sakai project github project everyone forks this project into their github account
  3. Clone your fork onto your computer
  4. Sync sakai master with your local forks master to receive updates
    1. Never work on your local master, generally this branch should always be the same as what is in sakai's master and if you make commits here this complicates things. If you mistakenly commit work to your local master, it's easy to fix
      master> git branch SAK-XYZ # make a copy of what we've done so far in a branch
      master> git reset --hard upstream/master # match current branch to upstream
      master> git checkout SAK-XYZ # resume work on feature branch

    2. Sync sakai master with your forks master

      master> git remote add upstream
      (you will do this only once)

      master> git pull upstream master
      (you will update your local fork frequently)

      master> git push origin master
      (after you update your local fork don't forget to push to your github fork) 


  5. Use your own copy of git to make your changes and test, etc. You can commit and push as to your own repo as much as you like.
    1. Make sure you always work on a local branch, We recommend using the name of the JIRA as the branch name.
      master> git checkout -b SAK-12345
      (make your changes then commit them, if you make multiple commits its best to squash them into one logical commit)
      SAK-12345> git push origin SAK-12345
      (this creates a new branch called SAK-12345 in your fork on github that contains everything in your local branch SAK-12345, notice they have the same name this is important)


  6. When you are ready to "commit to trunk" create a pull request from your repo against the sakai master branch in the sakaiproject repository.
    1. If the changes are code you would have committed to the old SVN trunk (i.e. just normal development) - merge your own pull request in to Sakai's master branch.
    2. If the changes you are making are worthy of further review or touching an area of Sakai that you do not generally work in - have someone else review and merge your pull request.
    3. If after review changes need to be made all you need to do is make the changes and commit in the SAME branch you issued the pull request (PR) from and then push those changes to your fork and it will automatically update the PR that was made to sakai's master.
      1. Find all the commits you want to squash together:
        SAK-12345> git log --pretty=oneline
        a931ac7c808e2471b22b5bd20f0cad046b1c5d0d commit1
        b76d157d507e819d7511132bdb5a80dd421d854f commit2


      2. Squash them together using the interactive rebase command (where 'HEAD~2' denotes you want to use the command on the last two commits since HEAD):
        SAK-12345> git rebase --interactive HEAD~2
        pick b76d157 commit2
        pick a931ac7 commit1
        # Rebase df23917..a931ac7 onto df23917
        # Commands:
        #  p, pick = use commit
        #  r, reword = use commit, but edit the commit message
        #  e, edit = use commit, but stop for amending
        #  s, squash = use commit, but meld into previous commit
        #  f, fixup = like "squash", but discard this commit's log message
        # If you remove a line here THAT COMMIT WILL BE LOST.
        # However, if you remove everything, the rebase will be aborted.


      3. Squash commit1 into commit2 by changing the prefix on the appropriate line:
        pick b76d157 commit2
        s a931ac7 commit1


      4. Change the commit messages if necessary in the following editor screen

      5. Push the changes back to the branch in your repo

        SAK-12345> git push --force origin SAK-12345


      6. Now your changes are all squashed into one commit, your repo branch is updated with your local code, and your PR is automatically updated without closing it and opening a new one!