How to undo a git rebase

Given the following situation:

  • You’re on feature/* branch and you have your latest changes already pushed to origin
  • Now, you want to rebase your feature/* branch with the latest master
  • You type in git rebase master from your feature/* branch
  • You fix all conflicts and finish the rebase
  • OH SHIT SOMETHING’S WRONG I NEED TO UNDO IT BUT HOW?

Okay, take a deep breath and just calm down. Use the following to reset it to your latest origin.

$~ git reset --hard ORIG_HEAD

That’s it. This will only work if you haven’t push your changes to origin yet. If you have, then you need to use git reflog

How to setup Jenkins with Docker

Here is an easy way to setup Jenkins with Docker

  1. Run the following commands in your terminal
docker pull jenkins/jenkins:lts
docker run --detach --publish 8080:8080 --volume
jenkins_home:/var/jenkins_home --name jenkins jenkins/jenkins:lts
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
  1. The above command will generate a password. Copy said password

  2. Open localhost:8080 and paste in the password

  3. Setup your user account and install suggested plugins.

That’s it!

What is the difference between Docker container and Docker image?

Today I learned the difference between image and container in Docker. An image is a template that can be used to create a container while container is the instances of said Docker images. The container is the one that runs your application.

To explain it in cake term, image is the recipe of the cake and container is the cake itself. You can create multiple cakes based on the same recipe.

To see all the images available, you can run the following:

$~ docker images

and to see the container that’s currently running, you can run:

$~ docker ps

or if you want to see the list of available containers, run:

$~ docker ps -a

That’s it. 🎂

References:

  1. https://stackoverflow.com/questions/23735149/what-is-the-difference-between-a-docker-image-and-a-container

How to Clone a Git Repository With Submodules

Today I learned how to git clone a repository that has git submodules inside of it. I realized that when I cloned a project it will clone the parent repo but the submodules will be empty. Here are the steps on how to clone it properly.

If you haven’t cloned the repository yet, you can use --recurse-submodules option:

$ git clone --recurse-submodules https://github.com/sample/sample-repo.git

Otherwise, If you already cloned the project then you can use the following command. Run the command inside your git repository.

$ git submodule update --init --recursive

This will initialize, fetch and checkout any nested submodules for the repository. That’s it.

How to fix Xcode: "Could Not Locate Device Support Files" error

There may be a time when you try to run your app in your device and you get the following error:

Could not locate device support files.

This iPhone (Model …) is running iOS 13.4 (11E608c), which may not be supported by this version of Xcode.

This issue usually happened when you are still developing your app using old version of Xcode but your device have already been upgraded to latest iOS version that is not supported by Xcode.

There are multiple ways to solve this issue:

  1. Upgrade your Xcode to the latest version - While this is the most obvious way to fix the issue, it could be your most hardest too. Depending on the situation, you might have to update all your projects issues before upgrading (Unsupported swift version, Unsupported SDK version, etc). That’s a lot of work
  2. Keep two versions of Xcode installed - This have been my preferred option whenever there’s a new iOS beta version dropped and I couldn’t wait to upgrade my device (living on the edge baby!). You have to symlink the DeviceSupport/ folder from the beta or latest version to the stable version that you’ve been using.1 However this option might not be feasible if you have a limited disk space on your machine.
  3. Copying the latest device support files to DeviceSupport folder - I just discovered this today and still in awe on how simple it is. I will list the steps down below.

To fix “Could Not Locate Device Support Files” Error Issue with new device support file

  1. Go to the following Github repo: iGhibli/iOS-DeviceSupport

  2. Find the zip files that’s matching your device’s iOS version and download it.

  3. Open the following path in Finder:

    $~ open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/
  4. Copy and paste the zip files that you have downloaded to DeviceSupport/ folder

  5. Close and restart your Xcode.

That’s it. You should be able to run your app in your device now. Hope you will find this tips useful.

Until next time. ✌️

References:

  1. github.com/iGhibli/iOS-DeviceSupport
  2. StackOverflow - Could not locate device support files in Xcode

  1. @steipete did an awesome job of maintaining a gist of the command to refer too. ↩︎