Skip to content
sbarrack edited this page Nov 20, 2019 · 3 revisions

How to Use Git CLI

Git is an industry standard package used for source code management. The command-line interface offers vastly greater control and user friendliness than the GUI version. Please read the whole page before accessing the repository.

Git jargon

Term Definition
repo short for repository, the code directory
origin the remote repo
clone the local repo
branch the code history is stored as a tree, each branch has different features
master the default branch
commit a node in the Git tree, think "save-point"
fetch updates your clone, does not apply new commits
pull updates the branch you are currently on with the latest commits
push updates the branch on origin with your new commits
merge merging two branches together
squash squashing all the changes from a group of commits into one commit
rebase rewriting history in the Git tree

Table of Contents

  1. Installation
  2. Cloning
  3. Committing
  4. Changing branches
  5. Pull requests

Installation

Please follow the instructions for your system.

Linux

Open a shell and type this to install Git. This is assuming you are using a Debian-based Linux distro.

sudo apt-get update
sudo apt-get install git -y

Mac

Open Terminal and type this to install Homebrew and, in turn, Git. If Homebrew is already installed on your system, execute only the last line of code.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew install git

Windows

  1. Go here git-scm.com/downloads
  2. Choose Windows
  3. Run the installer
  4. Choose exactly these components
    Git components
  5. Choose your editor; I recommend installing Visual Studio Code
    Git editor
  6. Leave the rest of the options as is and install

Top ^

Cloning

This will download the Git repo.

mkdir ~/GitHub
cd ~/GitHub
git clone https://github.com/AztecGameLab/LongTermGame2.git`

Afterwards, open UnityHub > Projects > Add to import the project. For Windows users, it downloads to C:/Users/You/GitHub/LongTermGame2.

UnityHub add project

Top ^

Committing

Commits are how we save work in Git. You need to commit frequently, rather than once a day, to ensure that we know exactly which changes were made that caused an error. I strongly recommend committing each time before you run code in the Unity3D editor at the bare minimum.

Before your first commit, please see Changing branches to switch to the correct branch that you are assigned.

  1. git fetch
  2. git pull
  3. If git pull failed for any reason, stop and talk to Stephen so we can trace the issue together
  4. Add all of your changes with git add ., or replace "." with a specific file name
  5. Commit your changes with git commit and it will prompt you to add an appropriate and descriptive message for that commit; type your message on the first line, and on the following lines, add any significant changes that you made; save the file when you are done
  6. Notify your team that you are pushing; once they agree, git push. If that fails, stop and get Stephen

Top ^

Changing branches

All members will be developing on the dev branch. You will not use the master branch.

  1. Commit any changes you currently have (see Committing), if any
  2. Execute git checkout branch, but replace "branch" with the name of the branch you are switching to

Top ^

Pull requests

Once your team has an update that is ready for master, you will submit a pull request which lists all the changes you made for it to be reviewed by one of the project leads.

  1. Go to the "Pull request" tab on the GitHub page for our repo and click "New pull request"
    Pull request
  2. Choose "master" as your base and your branch as your compare
  3. Submit the request

Top ^

Clone this wiki locally