GIT — How to use

Git is a system that version checks your Unity Project with your team.

Common commands to remember —

ls — list all of the common directories on your computer. Use this to get to specific folders like the desktop

cd —Change directories. Do this eg. cd Desktop/. Go deeper via adding more directories. If the name has a space, change the naming to “first last”.

Right-click, GitBash — this creates a gitbash terminal window that automatically has the pathway set.

git init — initializes a git depository in our project.

To add a repository, do this:

To verify it works, add this: git remote -v

In order to avoid merge conflicts, always pull, commit, then push. If you try to commit and push, you don’t take into account what others have done.

git — help — gets help info (it’s a double dash)

git pull origin main(replaces master) — pull from repository first (1)

git status — what files need to be added(2)

git add foldername/ — adds that particular folder name or git add . — adds all folders (3)

git commit -m “name of what you did” — second step to commit your changes (4)

git push origin main— commits everything to the github repository (5)

** in settings , revert back to Master for ease of use in the repository settings

Branches: as you switch between branches, your project will change in it’s content. Be sure to commit to one branch, then switch to the other branch to see changes.git

git branch — list all of the available branches

git branch nameofbranch — Create your own branch as a dev

git switch nameofbranch — now you are in the specific branch

git merge nameofbranch — merge branches together

Go back in time: want to go back to an earlier version? Here’s how.

git log — review old changes

git checkout #hashcode from old log

git checkout -b newname #hashcode from old log: converts it into it’s own branch

Reset the master branch to a previous time in history:

git reset — hard commit #hashcode

Unity Developer and Software Engineer who loves making games with GameDevHQ