How to Git in Unity- part 5

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.

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How To Manage Your Sessions IN Golang Using Gin Framework And Redis ?

Prevent OOM Errors Training Large Models using Lightning and PyTorch Meta Tensors (Part II)

Introducing Letterpad — A CMS for blogs

JWT Summary

Flutter: Inbuild List methods in Dart

Managing Seasonal Traffic with AWS

Life is a journey of twists and turns, peaks and valleys, mountains to climb and oceans to explore.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
S.J. Jason Liu

S.J. Jason Liu

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

More from Medium

Creating a Simple Cooldown System in Unity Using Time.time

Balancing Static & Dynamic Objects when Baking In Unity

Aiming Features in Cinemachine

Hidden Shortcuts to Make Level Design Easier