Skip to content

Using GitHub

Christof Steyn edited this page May 7, 2023 · 3 revisions

General Rules

  1. Do not commit anything to main/master unless widely discussed with others and everyone has agreed.
  2. If you have a merge conflict or any issue don't just delete, ask someone for help.

General Functionality

This document will look at working with GitHub desktop, VS Code (terminal and extension) and IntelliJ

GitHub Desktop

  1. Check that you are the correct repository in the top left.
  2. Check that you are in the correct branch
    • you can create a branch if you feel you need to, however ensure that the branch doesn't already exist.
    • when creating branches name correctly:
      • feature branches get feature/branchname
      • front end branches get front-end/branchname
      • etc.
  3. If there are local changes to the branch pull them. (Big blue "pull" notification)
  4. Fetching origin will fetch any changes to the remote repo. (Won't download just checking if there are updates)
  5. Open in VS Code (button in the middle)
  6. Once you have started coding:
    • you will be able to see any changes made in GitHub desktop
    • you can stash any changes in GitHub desktop (This means that the changes you've made will be saved and you can pull into your current branch)
    • once finished coding commit your work on GitHub desktop
    • you will need to supply a Summary heading and message when committing
    • ensure that your message isn't longer than 50 characters (the less, the better), explain what and why.
  7. Push commits

VS Code/terminal

  1. Open the copied folder in VS Code. This should automatically activate git.
  2. If you have never done this before sign into your git account using either in the terminal:
    • $ git config --global user.name "Your name here"
    • $ git config --global user.email "user.email"
  3. Ensure that the source control in VS Code (3rd icon from the top on the left) shows "message" and "commit".
  4. In the terminal type "git branch", the branch you are in will have a star next to it.
  5. If you are not in the branch that you should be working in then in the terminal type "git checkout 'branchname'".
  6. Ensure you're in the correct branch.
  7. If a branch you are looking for isn't there try "git fetch origin" and try again
  8. In the terminal type git status, if you are not 'up to date' type "git pull"
  9. Once finished coding, your changes should show in the source control tab.
  10. You can stash, stage and commit your changes in the source control tab.
  11. VS Code also provides an interface to view merge conflicts.

Jetbrains IntelliJ

  1. Download the IntelliJ Ultimate edition from the Jetbrains website:
https://www.jetbrains.com/idea/download/#section=windows
  1. When launching IntelliJ for the first time, press the login link at the bottom left of the popup.
  2. Login using your student email and password
  3. On the welcome page click the "Get from VCS" option.
  4. Enter the repository URL and choose where to save the project locally.
  5. Check that you are in the correct branch. The current branch is shown on the bottom right of IntelliJ.
  6. By clicking on the branch you can also change to another branch or even create a new one to work on.
  7. To fetch and pull updates from the repo, simply click the blue arrow on the top right and select the "merge incoming changes" option.
  8. To commit changes, simply click the green check symbol on the top right corner. This will bring up a changes tab on the left where you can see the modified/added data. Also provide a Short and detailed commit message that states what you have changed.
  9. Either commit and push directly to the branch or commit and push later by clicking the green arrow on the top right corner of IntelliJ.

Merge conflicts

If you run into a merge conflict message, and you don't understand the conflicts once viewing them, contact the person who may be responsible for the changes (can be view in commit history) or contact the project manager.