How to Git in Unity- part 5

S.J. Jason Liu
3 min readApr 25, 2021

Previous article: How to Git in Unity- part 4

As version control, if we want to recover the old version or changes, we can reverting or resetting our branch. Further more, we can even force the version back to where we want(although it might be extremely danger).

1.First, we need to locate the commit hash code by input:
git log

2. Find out the commit that we want to revert, then copy it.

3. You can take a peek by using checkout(not switch in this case).

now it’s in the specific section that shows in blue

4. The result will reveal in your Unity project.

before checkout the commit
after checkout the commit

5. Then we can create a new branch for this reverted old section by using:
git checkout -b <new branch name> <commit hash code>

6. Now you have a new branch with reverted version.

After resetting the old section with new branch, we can also force reverting the branch back to where we want and overwrite all the changes.

1.We can choose the section we want and copy the hash code in Github.

2. Then we can reset the current version of main by using:
git reset ––hard <commit hash code>
*
(there are 1 space and 2 dash after the reset)

3. You can see the result in Unity.

before reset
after reset

4. If you really want to force it as your latest update, you can input:
git push ––force origin main
*(there are1 space and 2 dash after the push)

5. Now your main branch in Github should reversed to where you want, and all the changes were gone.
But the other branch will stay same.

That’s all for How to Git in Unity series.

--

--

S.J. Jason Liu

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