Today I learned!

#7 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

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

#6 How to setup Jenkins with Docker

Here’s how 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!


#5: How to make smerge available in your command line

smerge is a command line tools for Sublime Merge. To make this tools available in your command line, you have to symlink it. Here’s the command on how to do it for macOS:

 ln -s "/Applications/Sublime Merge.app/Contents/SharedSupport/bin/smerge" /usr/local/bin/smerge

That’s it. After this, you can easily browse your repo in Sublime Merge just by typing smerge in your CLI.

For Windows or Linux, you can check Sublime Merge’s docs.


#4: How to install latest node version with nvm

Today I learned how to install or update my Node.js version to the latest stable version with nvm.

To update to the latest stable version, simply run:

$~ nvm install stable

This will also set the installed node as the default. That’s it

#tools #node

#3: 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


#2: How to install latest stable ruby version with rbenv

Today I learned a simple solution to install the latest stable ruby version with rbenv. If you are using rbenv to maintain your ruby versions but you couldn’t be bothered to keep track of the releases and just want a stable version, you can use the following command:

$ rbenv install $(rbenv install -l | grep -v - | tail -1)

This command will get the latest stable ruby release and install it with rbenv install. That’s it.

References: https://stackoverflow.com/questions/30179484/install-latest-stable-version-of-ruby-using-rbenv


#1: How to clone 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.