Categories
Git

Recover a Lost or Missing Commit in Git

Recover a Lost or Missing Commit in Git

If you have ever lost a commit in Git, don’t worry there might be still a chance to recover it. For example I encountered a problem with Git, when I was pushing my commit to the remote server. For some reason my Git client had some error when sending the commit to the remote server. So the commit didn’t go through and the Git client deleted all my local modifications from my local machine. So I couldn’t try to send the commit again (as Git said there’s no modifications / commit to send). Basically it reset all my files to the state that they were when I last time made a successful commit to the server. Fortunately I found a way to dig up the lost commit and modifications that I have made with git reflog. Go inside your project folder, and then run the following:

git reflog

Now you should see a log of what has happened in your local repository. Every action that you have taken in your local repository (in your your local computer) should have an ID and what kind of action is it. So for example I found my lost commit few rows below in the log. The lost commit is in a form of “db123456 HEAD commit: your commit message”. Write down the ID string (in my example it’s the 8 characters long string “db123456”). Before we try to recover the lost commit, you should backup your project folder just in case, if something goes wrong or you need to try recovering again.

 

We will next reset the local git repository. Remember it will delete any modifications that you have made after the lost commit. So if you have multiple missing commits, then you should maybe try to recover them one by one. That’s why I recommend backup your project folder before recovering. To get back your missing commit, run the following command (remember to replace the ID with your ID that you have written down):

git reset --hard db123456

Now hopefully you should have recovered your lost commit.

Sources:

Categories
Game development in Linux

How to install Unity game engine and Rider IDE in Pop OS / Ubuntu

How to install Unity game engine and Rider IDE in Pop OS / Ubuntu

This is a quick guide how to install Unity game engine and Jetbrain’s Rider IDE and necessary dependencies. First we will start from installing Mono (the open source implementation of .NET framework), as otherwise the Rider can’t work correctly. The installation process differs a bit from which Linux distro you are using and which version. You can see the install instructions here: https://www.mono-project.com/download/stable/

 

For example for distros that are based on Ubuntu 20.04 (like Pop OS 20.04), you can install Mono with the following commands:

sudo apt install gnupg ca-certificates
sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo “deb https://download.mono-project.com/repo/ubuntu stable-focal main” | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel

 

Next we will install Rider. There’s two different ways to install Rider. One way is to download from their web-site (https://www.jetbrains.com/rider/download/#section=linux) or download through Snap package manager. I will be using the Snap package manager way. For Pop OS, we need to install Snap package manager, as it doesn’t come with it by default. Ubuntu users can skip this step.

sudo apt install snapd

 

Then we will install Rider

sudo snap install rider --classic

 

This step is optional. The Unity Hub is distributed as an AppImage, but due to the nature of AppImage (as it more like an isolated image that you run), the Unity Hub might not integrate that well to your system. For example I noticed as I use Planck dock to start my apps, I had troubles to add the Unity Hub to the dock permanently. But I found a solution: to use AppImageLauncher (https://github.com/TheAssassin/AppImageLauncher). Depending of your needs this step isn’t mandatory, but for example if you experience any problems with Unity Hub and Planck dock, I can recommend this one. You can install AppImageLauncher with the following commands:

sudo add-apt-repository ppa:appimagelauncher-team/stable
sudo apt update
sudo apt install appimagelauncher

Next we will install Unity. Head to https://unity3d.com/get-unity/download and download the Unity Hub to a folder that you want to run it from. Then with shell to that folder and run the following command (to allow the UnityHub.AppImage to run):

chmod +x UnityHub.AppImage

 

If you installed the optional AppImageLauncher, right click the UnityHub.AppImage as choose run with AppImageLauncher. The AppImageLaucher should no pop up and ask, if you want to integrate the UnityHub to the system.

After you have started Unity Hub, recover your license, and download the Unity version that you want. 

NOTE: Before you can add an older Unity project to Unity Hub, you have to create a new project first. For some reason there’s currently a bug that the add project button doesn’t work until you have created at least one new Unity project. After that you can add your previous Unity projects in Unity Hub.

NOTE: If you want to install a specific version of Unity (not the latest one), unfortunately the Unity Hub links in Unity download archive don’t work currently in Linux. But there’s fortunately a workaround for this problem: Go to Unity download archive (https://unity3d.com/get-unity/download/archive) and go to the Unity version that you want, and right click on the Unity Hub download link, and choose copy link. The link should be in form of “unityhub://2021.1.16f1/5fa502fca597”.

 

Now with your shell, go to the folder where your UnityHub.AppImage is and run the following command (replace the link with the link that you copied before):

./UnityHub.AppImage unityhub://2021.1.16f1/5fa502fca597

 

The Unity Hub should now open and it should ask if you want to install that version.

Sources: