Skip to content

Eti git

Oliver edited this page Oct 27, 2021 · 2 revisions

This document uses git on the command line, bash specifically. You can follow this generally using Windows (with either git-bash or some other prompt that mimics Bash)


Useful Videos


General Guidelines:

  • The main branch is the latest working version of the game's code.
  • When writing code, create a branch off of develop (NOT main) with a name following the guide below:
    • Feature Branch = feature/feature-name-here (e.g. feature/enemy-ai)
    • Bug Fix Branch = fix/bug-name (e.g. fix/no-collision-walls)
    • Beyond that, use your best judgement on branch names. If we can't tell the purpose of the branch from the name, it's not a good name.
  • Commit working code as one unit. If that consists of more than 1 file, commit all the relevant files as needed for it work. This makes reverting easier if it is ever needed.
  • When done working on a branch:
    • Open a pull request from your branch, into develop.
    • In the future, this will trigger an automated process that attempts to compile the project using Unity. If your branch doesn't compile, it will be blocked from being merged and you will need to fix the problems. If the branch does compile properly, your PR will be allowed to merge.
    • If your branch doesn't get blocked from merging, you can merge it into develop. This can be done without approval, but getting a review from someone else can be very beneficial and is extremely recommended.

Writing The Code:

Repo Not On Computer:

  1. Clone the repo (ssh key): (REPLACE BRANCH_NAME in the command) git clone [email protected]:Oliver-Akins/CMPT-306-Group-Game.git -b BRANCH_NAME
  2. Edit the code in whatever way you want.
  3. Commit your changes. (git commit)
    • Any new files you will need to git add before committing.
  4. Push your changes. (git push)
    • If git says something about being out of date, try git pulling and then git push

Repo On Your Computer Already:

  1. Make sure you're on the right branch. (git status)
    • If you're on the wrong branch, run git checkout origin/BRANCH_NAME replacing BRANCH_NAME with the name of the branch you're wanting to work on. Confirm the change by running git status again.
    • Atlassian Git Checkout Tutorial
  2. Pull changes. git pull
  3. Edit the code in whatever way you want.
  4. Commit your changes. (git commit)
    • Any new files you will need to git add before committing.
  5. Push your changes. (git push)
    • If git says something about being out of date, try git pulling and then git push

Merge conflicts can be handled with ease by opening the repository in Visual Studio Code


Tricks and Recommendations:

  • Auto-save is good.
  • Auto-add is bad. (Can't see the git diff, meaning that you don't know what you're committing to the repository with the commit)
  • git diff is handy.
  • git stash is super handy for temporarily saving files that you want to change without copy/pasting them to another file.
  • git branch lists all local branches in your repo.
  • git checkout -b BRANCH_NAME creates a new local branch.
  • git fetch can be used to update the local repo with changes from the remote repo without downloading all of the files, branches, etc. in the repo.
Clone this wiki locally