How to Git in Unity- part 3

S.J. Jason Liu
2 min readApr 23, 2021

--

You can review the previous articles here:
Part 1, Part 2

Before we start to commit and push our update. We need to follow the steps to do it right in version control.
While a project is sharing between all the co-workers, some changes might lost if we didn’t follow the steps properly.
Always do the version control by:

PULL, COMMIT, PUSH
Make sure you pull the latest version of changes, then commit your part, then push it to repository.

Now we’re going to push our local files to repo.
As I mentioned in the previous article, we need to make the branch to main(which is default as master) first to prevent error.

1.We can create new branch by input:
git branch -b main

2. With same namespace, it should be error free to pull from remote repo:
git pull origin main

3. You can always check the status by the command:
git status
The red parts show the local changes different from remote repo.

4. Add all the changes to be pushed by input:
git add .
the period is the key which means “add all the files”.

5. Then we can push our changes to repo:
git push origin main

6. After pushed, we can delete the empty branch “master”
Before we do it, we can make sure the current branches:
git branch
It should reveal 2 branches, main(with star mark) and master.

7. Now you can delete branch master:
git branch -D master (upper letter D to force delete)

That’s it! Now you successfully push the branch “main” and without any error.

Next: How to Git in Unity- part 4

--

--

S.J. Jason Liu
S.J. Jason Liu

Written by S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

No responses yet