Git: Copy a file between branches

October 30, 2019

Let's assume we have a two branches (A, B), and we want to move the file test.xt from branch A to branch B.

git checkout B
git checkout A -- test.txt
git status
git commit -m "Copy file test.txt
git push

Git: Delete commits history

May 16, 2019

You can not delete the commit history from a branch, but you can create a new branch (without history because is new), push the files to the new branch and then delete the old branch.

The next example shows how to recreate the master branch.

# Create temporary branch
$ git checkout --orphan temp

# Add and commit all the files
$ git add -A
$ git commit -m "init"

# Delete current branch
$ git branch -D master

# Rename current branch to master
$ git branch -m master

# Push all the files to the new master branch
$ git push -f origin master

Ansible: for each loop

March 29, 2019

Example of how to do a for each (foreach) loop in a task with a predefined dictionary.

Example on Python

for key, value in dictionary.items():
    # do stuff

Example on PHP

foreach ($dictionary as $key => $value) {
    # do stuff
Read more

Kubectl autocompletion in MacOS

March 20, 2019

MacOS comes with a really old bash version. Check the version from the environment variable..


We can install a newer version of bash via Homebrew package manager, get Homebrew from here

Read more

Kops commands

March 7, 2019

Quick commands for Kops.

First set the environment variable $NAME and KOPS_STATE_STORE.

$ export
$ export KOPS_STATE_STORE=s3://kops
Read more