Project

General

Profile

Actions

Git-MAUS

Besides Launchpad and bazaar MAUS has beta level support for git andgithub. At the moment code updates for the trunk cannot be accepted from github however, only via Launchpad and bazaar.

Overview

This following section will guide you to:

  1. Create an account on GitHub
  2. Add an ssh key to your account
  3. Fork the MAUS repository on github into your personal github account
  4. Make a local copy on your computer of your fork of MAUS
  5. Create a new development branch within this repository locally
  6. Make and changes and commit these changes to this branch
  7. Push your development branch and these changes to your github MAUS fork
  8. Create a Jenkins test server job for your development branch
  9. Propose merging your changes back to the MAUS trunk via github
  10. Merge changes from the MAUS trunk into your development branch

Step-by-step guide

  1. Create an account on github
  2. Add an ssh key to your account
  3. Fork the MAUS repository on github into your personal github account
    1. Go to MAUS github page and login into github
    2. Click "Fork" in the top right of the screen, selecting the option to fork to your own account
    3. Select your own account from the options that appear for where to fork MAUS
  4. Make a local copy (clone) on your computer of your fork of MAUS
    1. Copy the address of your new fork from github (something like git@github.com:jbloggs/maus.git, where jbloggs is your github username)
    2. Clone your repository:
      git clone git@github.com:jbloggs/maus.git
      
  5. Create a new development branch within this repository locally
    1. cd into the directory created by the clone command (maus by default)
    2. Take a look at the branches present with:
      git branch -av
      
    3. Pull down the merge branch from your remote github repository into the new local repository:
      git checkout merge
      
    4. Create a new development branch in the local repository by forking the merge branch:
      git checkout -b my-feature-branch
      
    5. Observe the new state of your local repository with:
      git branch -av
      

      A note on nomenclature: The original repository you fork from on github is usually referred to as the upstream repository. Any repository you clone from is by default named origin. Here upstream refers to the central MAUS github repository, and origin refers to your fork of it on github.
      When on github do not confuse the upstream MAUS repository with your fork!
  6. Make changes and commit these changes to the local development branch
    1. Edit some files, creating some wonderful new feature for the benefit of mousekind
    2. Stage the changes:
      git add AlteredFile1.cc AlteredFile2.cc
      
    3. Commit the changes:
      git commit -m 'My excellent new feature, closing issue ###'
      
  7. Push your development branch and these changes to your github MAUS fork
    git push origin my-feature-branch
    
  8. Create a Jenkins test server job for your development branch
    1. The MAUS test server can be found at: http://test.mice.rl.ac.uk
    2. Either email the head of MAUS requesting a test branch and giving your repository url and development branch id, or go to the test server, create a new item, copying an existing git-based test job, and edit the configuration with your repository url and branch name
  9. Propose merging your changes back to the MAUS trunk via github
    1. Run the Jenkins test server job on your development branch
    2. When Jenkins has passed (and not before), return to your repository page on github and select my-feature-branch from the drop-down menu on the left (below is an example where the feature branch is named event-selection)
    3. Click the "Pull request" button to propose merging into the trunk
    4. Make sure your branch is comfortable for merging, that is it does not lead to any conflicts when github attempts a mock merge into the central MAUS merge branch. If your branch is not comfortable for merging, edit some more until it is, commit and push, then try again
    5. Creating a pull request will alter the MAUS maintainers you want your code added to the trunk, and begin a conversation between you and them if any changes are required first
  10. Merge changes from the MAUS trunk into your development branch
    1. One reason your development branch may not automatically be comfortable for merging back in the central MAUS merge branch is if someone has pushed changes there since you forked your repository. This can be dealt with by merging the changes from the central MAUS repository into your repository.
    2. First, we must tell your local copy of your repository about the central MAUS repository on github. This is called adding are remote. Note your local repository already has one remote, your repository on github - it has the default name origin. Add the central MAUS repository on github as a new remote called upstream with:
      git remote add upstream git@github.com:mice-software/maus.git
      
    3. Look at your repository structure again with:
      git branch -av
      
    4. Make sure we are in our feature branch:
      git checkout my-feature-branch
      
    5. Now merge from the central MAUS merge branch into your feature branch with:
      git pull upstream merge
      
    6. If there are any conflicts listed, examine each file in turn, make the changes needed, and then resolve the conflicts with:
      git add MyFixedFile.cc
      

      Commit the changes made if you resolved conflicts with:
      git commit -m 'Merged from the trunk'
      
    7. Now push the changes back to your github repository with:
      git push origin my-feature-branch
      

Useful git commands

See https://www.git-tower.com/blog/git-cheat-sheet/

Updated by Dobbs, Adam over 4 years ago ยท 44 revisions