Git Process - RobotGirls/FTC-Team-25 GitHub Wiki

This page seeks to describe the steps for using Git on the teams.

Formatting note: items in the gray boxes are meant to be typed or pasted into your terminal. Anything in <Angle Brackets> needs to be replaced by the correct value for your use case.

Standard Meeting Start

At the start of a standard meeting, where you are working on a feature that you or someone else was working on last time, follow these steps:

  1. Open your terminal. This can be the terminal program on a Mac or Git Bash on a PC.
  2. If you are working on a modification to Terkel, check out the correct branch for Terkel. Note: Most of the time, you will not be making updates to Terkel so these steps can be skipped.
    1. Type: goterkel
    2. Perform a git fetch
    3. Ensure you are on the right branch by git checkout <branch name>
    4. Perform a git status
    5. If you are not up to date, perform a git pull
  3. Check out the correct branch for your team code.
    1. Depending on the team, type go25 or go5218
    2. Perform a git fetch
    3. Ensure you are on the right branch by git checkout <branch name>
    4. Perform a git status
    5. If you are not up to date, perform a git pull
  4. You are now ready to work on your code!

Meeting End

At the end of each meeting, you should push the latest version of your code. This is to ensure that your progress isn't lost if you're not the next person to work on the code (for example, if you can't make the next meeting) or if something happens to your computer (computers have died mid-season before).

  1. Open your terminal. This can be the terminal program on a Mac or Git Bash on a PC.
  2. If you are working on a modification to Terkel, check out the correct branch for Terkel. Note: Most of the time, you will not be making updates to Terkel so these steps can be skipped.
    1. Type: goterkel
    2. Perform a git fetch
    3. Ensure you are on the right branch by git checkout <branch name>
    4. Perform a git status
    5. Add the files you have worked on with git add <file>
      1. Repeat this step for as many files as you have changed
    6. Write a commit message that tells us what you changed in these files. Good commit messages are short and specific. For example: "Created wrapper class for HuskyLens Camera" or "Updated ColorSensorTask to include a getColors function"
      1. git commit -m "<Commit message inside the quotes>"
    7. Push your changes with git push
  3. Check out the correct branch for your team code.
    1. Depending on the team, type go25 or go5218
    2. Perform a git fetch
    3. Ensure you are on the right branch by git checkout <branch name>
    4. Perform a git status
    5. Add the files you have worked on with git add <file>
      1. Repeat this step for as many files as you have changed
    6. Write a commit message that tells us what you changed in these files. Good commit messages are short and specific. For example: "Updated autonomous path so the robot now turns right instead of left" or "Changed the power on the lift motor to prevent string snapping"
      1. git commit -m "<Commit message inside the quotes>"
    7. Push your changes with git push
  4. You have now pushed your code and are done for the meeting!

Starting a New Branch

When you want to start on a new feature for your code, there are several steps.

  1. Open a GitHub Issue in the appropriate repository where you will be making the changes.
    1. This could be in your team code repository (FTC-Team-25 and FTC-Team-5218, respectively) if you are updating a Teleop or Autonomous, or in Terkel if you are updating how a class works/making a new class.
    2. In your web browser, navigate to the correct repo, and click on "Issues" at the top of the page.
    3. Click on the green "New Issue" button on the right side of the page.
    4. Give your issue a descriptive title. Some examples include "Implement Autonomous path for position 1" or "Add drone-launching servo control code"
      1. NOTE: Issues are meant to be features that are being implemented. They are NOT supposed to be things like "Software for LM0" or anything that does not describe what work is being done in the code.
    5. Give your issue some more information in the "Leave a comment" box. This can include what you're thinking for what the autonomous path does or what kind of servo you are using.
    6. Click on the green "Submit new issue" button at the bottom.
    7. On the right side of the screen, there is a field called "Assignees," and a little gear icon next to it. If you're going to start work on this soon, assign yourself.
  2. Update your local master branch.
    1. Open your terminal. This can be the terminal program on a Mac or Git Bash on a PC.
    2. Navigate to the correct repo. This can be goterkel, go25, or go5218, depending on the repo you are working on.
    3. Perform a git fetch
    4. git checkout master
    5. Perform a git status
    6. If you are not up to date, perform a git pull
  3. Make a new branch
    1. git checkout -b issue-<issue number from github>
  4. Push your new branch onto github with git push --set-upstream origin issue-<issue number from github>
  5. You are now ready to work on your code! Remember to push your changes at the end of the meeting!

Merge Code Back into Master

When your new feature is working, you are ready to merge it back into the main branch so that the rest of your team can benefit from your hard work.

  1. Make sure your latest changes are committed and pushed! See the Meeting End steps for how to push if you need them.
  2. Make sure your local master branch is up to date.
    1. Open your terminal. This can be the terminal program on a Mac or Git Bash on a PC.
    2. Navigate to the correct repo. This can be goterkel, go25, or go5218, depending on the repo you are working on.
    3. Perform a git fetch
    4. git checkout master
    5. Perform a git status
    6. If you are not up to date, perform a git pull
  3. Check out your working branch with git checkout <branch name>
  4. Perform the merge of the master branch into your branch.
    1. git merge master
    2. If there are no merge conflicts, a Vi editor should open and show a commit message stating that a merge occurred. Type :wq to save the commit message. Push your changes with git push and skip ahead to "Test your merged code".
    3. If there are merge conflicts, there will be a terminal message telling you that. Perform a git status to get a list of "Both changed" files.
    4. For each file on the "Both changed" list:
      1. Open the file in Android Studio
      2. Search for <<<<<. This shows the start of the merge conflict.
      3. Review the differences between your branch and the master branch, and keep the changes that you want to keep. Discard the changes you don't want by deleting the lines between <<<<< and ===== or between ===== and >>>>>. Make sure those three lines (<<<<<, =====, and >>>>>) are also removed.
      4. Once those three lines (<<<<<, =====, and >>>>>) have been removed every place they appear in the file, add the file with git add <file>
      5. Repeat these steps for every file on the "Both changed" list.
    5. Once all file conflicts have been resolved, perform a git status. See that there are no files in the "Both changed" list.
    6. Perform a git commit with no -m. This will open a Vi editor showing a commit message stating that a merge occurred. Type :wq to save the commit message.
    7. Push your changes with git push
  5. Test your merged code.
    1. Build and test the code on the robot.
    2. If it works as expected, great! Continue to the next step.
    3. If it does not work as expected, stop these steps and ask a mentor for help.
  6. Open a Pull Request on GitHub.
    1. In your web browser, navigate to the correct repo, and click on "Pull Requests" at the top of the page.
    2. Click on the green "New Pull Request" button on the right side of the page.
    3. Under "Compare Changes," there are two drop down menus. For the first, select "base: master." For the second, select "compare: <your branch name>"
    4. Click on the green "Create Pull Request" button on the right side of the page.
    5. Give the pull request a name that includes "Issue <issue number from Github>"
    6. In the description of the pull request, leave a comment stating what you've changed. This could be as simple as copying the description from the issue if that is all you did to as descriptive as you would like to be.
      1. As part of the description, include "Implements issue #<issue number from Github>". When the pull request is merged, it will automatically close the issue.
    7. There is probably a save button that needs to be clicked somewhere in here.
    8. An email will be generated to the mentors asking them to review your pull request. This is to make sure code isn't merged in that shouldn't be.
    9. A mentor might request some changes to your code. For example, a mentor might request you add some comments to your code, or remove some code that is commented out. Make the changes that are requested (or discuss with the mentor why you think they aren't needed), and commit/push the changes like you always do.
    10. Once a mentor approves the pull request, they can merge your feature branch with the master branch. At this point, everyone on your team should perform a git pull on their local master branch, including you.
  7. Once the pull request is merged, your code is now live on the master branch! You can start working on your next feature!
⚠️ **GitHub.com Fallback** ⚠️