Skip to content

Fregnen/Semester-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

  1. Instructions for Git
    1. First Time User
    2. Terms
    3. Cloning a Repository
    4. Working on a Project
      1. Git Bash
      2. Get an Overview
      3. Branches
      4. Add, Commit, and Push
      5. Fetch and Pull
  2. Instructions for Unity

Instructions for Git

This is an overview of how to use Git. In the next section, you can also see how to name files and gameObjects to keep consistency, making it easier to navigate the Unity project.

First Time User

If not already done, do this first:

  • Make a GitHub account
  • Install Git with Bash
    • Bash is Git's shell. You can use other shells, this is just the one I have learned how to use.

Terms

There are 3 different staged:

  • Locally (e.g. work in Unity), which is then...
  • ... is committed (saved in local versions), which then can be...
  • ... pushed to the remote version (online), which can be pulled by others.

Cloning a Repository

When you want to clone a repository, you have to choose the folder where you want to save the repository. I recommend saving it on your SSD 💡

Example If you want to have the repository on , go to the parent folder of . Then, right-click the folder and choose GIT Bash. A window should show up, where you write

git clone https://github.com/Fregnen/Semester-Project

You should now see the repository Semester-Project in (or whatever folder you chose). Every time you clone a repository, install lfs:

git lfs install

This is telling Git that we are working with large files storage, such as Unity projects.

Working on a Project

This is where we all need to focus❗ To get a better understanding of how Git works, how branches, commits and merges are performed, here an interactive tutorial ℹ️

Git Bash

To open GIT Bash, open the folder (Semester-Project). Click inside the folder (just on the white/black area, where no files are shown) and choose GIT Bash.

Get an Overview

Here are different commands, which you can use to get an overview of the repository. Also see Fetch and Pull.

Git Status

When beginning your work and after every command, use

git status

This gives a summary of your local status on the specific branch, you are working on. This is not compared with what is actually in the remote (online) version, but in comparison to the last time you have pushed or pulled.

Git Branch

git branch                          list all the branches in the local machine
git branch -a                       list all the branches (local + remote)
git branch -av                      list all the branches (local + remote) with comments

Branches

Because we under NO circumstances want to make mistakes on main, we will for each feature you are working on, make a branch. These branches will be merged with main, when they are functioning as they should - but only by the Git Master. In this way we make sure that mistakes are only made on one branch and can be reverted, without it affecting the main.

New Branch

Making a new branch and moving HEAD to it, type in Git Bash:

git checkout -b "BranchName"

Make sure that the name makes sense, when you create it. There are other methods to create a branch, which is seen in the tutorial previously linked. When having created and moved HEAD to the new branch, make sure to install lfs:

git lfs install

Now, check status to see that you are working on the branch with:

git status

Change Branch

Change the branch you are working on with

git switch <BranchName>

Delete Branch

You cannot delete branches that you are working on, so checkout other branches first. Also, talk with the Git Master if in doubt of whether the branch should be merged with main before deleting - unless you have merged it with a branch you're already working on.

git branch -d BranchName

The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet.

Add, Commit, and Push

These are the steps for updating the local or remote repository.

Add

See status first, make sure you are working in the correct branch. This will also show if you have made any local changes. This will be shown by red font. These files are edited, but Git does not know if they are edited purposefully, hence showing you them. You now have to choose what files you want to add to your commit. You can either choose a specific file to add with:

git add <FileName>

or all files with

git add .

Remember to see git status, to make sure Git added the files you want. Now you can go on to commit. If you want to remove a file, which you do not want to commit:

# For all files:
git restore .

# For specific file
git restore --staged <file name>

Commit

Here, you make a local save, which you can revert back to if something goes wrong later on. Please leave a message on what changes you have made to make it easier to follow the process but also to be able to remember what commit is working if you need to revert back to it. Use the command:

git commit -m "Your message here"

Again, get a git status, to make sure that what you just committed is the latest and that you are now working on this (have moved the HEAD with the commit).

If you find your work too messy to commit but still want to save the changes --> read here.

Regretting a Commit

This command will remove the last commit from the current branch, but the file changes will stay in your working tree. Also the changes will stay on your index, so following with a git commit will create a commit with the exact same changes as the commit you "removed" before.

git reset --soft HEAD~1

More information ℹ️

Push

When you want to share your progress on the branch you are working on, you can push the local to the remote repository. When creating something that everyone should have in their own version, you can make a pull request.

Again, always get an overview of where you are in the working tree (see Get an Overview).

Fetch and Pull

To get an overview of what has happened remotely - also on other branches and where you are.

git fetch
git status

If you want the changes, merge it with

git merge origin/<otherbranch>

If you want to just get the updates, you can immediately pull with

git pull

See the difference on fetch and pull here --> ℹ️

Instructions for Unity 🚧

In Unity, we will work in different scenes, which makes it easier for the Git Master to distinguish the changes made by who.
Examples of naming and commenting
Naming conventions
Naming conventions 2

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published