How to set up free merge and diff tool (p4merge) for GIT

This is just a backup of this article as I found it very handy:

  1. Install p4merge from
  2. Add below to your .gitconfig
keepBackup = false
tool = p4merge
[mergetool “p4merge”]
cmd = /Applications/ “\”$PWD/$BASE\”” “\”$PWD/$REMOTE\”” “\”$PWD/$LOCAL\”” “\”$PWD/$MERGED\””
keepTemporaries = false
trustExitCode = false
keepBackup = false
tool = p4merge
[difftool “p4merge”]
cmd = /Applications/ “\”$REMOTE\”” “\”$LOCAL\””

Adding a command Alias to git

Imagine you wan to run:

git log –all –graph –decorate –oneline

But you don’t wan t to write all that each time but instead something shorter like “logh”

Well you can add a “git alias” in this way:

git config –global alias.logh “log –all –graph –decorate –oneline”

Voila, go and try it out! just do “git logh” in your desired repository

Tip: if you want you can edit this alias and other settings editing this file:

vi ~/.gitconfig

Git quick-start basics

Hi there you are reading my Git notes for a basic quickstart Git demo flow, I intend to cleanup in the future but in the meantime feel free to look-around and let me know if you have any doubts.

Git starts with the branch “Master” by default (when you create a new repository)

Git has 3 states:

  1. Working directory (local folder)
  2. Staging (Git index) temporary space
  3. Commit (.git folder) repository, changes history

You can add a 4 state the “Remote”

Windows install


Mac (already installed in latest Mac), probably best to install Xcode first

  •  git version
    git version 2.15.2 (Apple Git-101.1)


Ok… so lets get started:

  • Login to GitHub and create a new repository
  • Get the HTTS address to clone it i.e.


  • $ cd github-demo/
  • $ ls
  • $ cat
    # github-demo
    Another simple demo repository to show the basic Git workflow
  • $ git status
    On branch master
    Your branch is up to date with ‘origin/master’.
    nothing to commit, working tree clean

Origin (Git automatically sets a relationship with GitHub and says it’s up to date)
It also says that our working directory is clean

  • $ echo “Just a dummy file to demo Git’s file tracking” >> start.txt
  • $ git status
    On branch master
    Your branch is up to date with ‘origin/master’.
    Untracked files:
      (use “git add <file>…” to include in what will be committed)
    nothing added to commit but untracked files present (use “git add” to track)

Git complains the added file is untracked
Lets add it to staging area:

  • $ git add start.txt
  • $ git status
    On branch master
    Your branch is up to date with ‘origin/master’.
    Changes to be committed:
      (use “git reset HEAD <file>…” to unstage)
    new file:   start.txt

Now the file is waiting to be commited (no changes into the repository {history of commits})
Saging area is designed so you can make changes without affecting the Commits history and can be added as a single atomic unique (all changes at once to a commit)

Ok lets commit it to local repository using git commit -m (m stands for message)

git commit -help

usage: git commit [<options>] [–] <pathspec>…

  •     -q, –quiet           suppress summary after successful commit
  •     -v, –verbose         show diff in commit message template

Commit message options

  •     -F, –file <file>     read message from file
  •     –author <author>     override author for commit
  •     –date <date>         override date for commit
  •     -m, –message <message>
  •                           commit message
  •     -c, –reedit-message <commit>
  •                           reuse and edit message from specified commit
  •     -C, –reuse-message <commit>
  •                           reuse message from specified commit
  •     –fixup <commit>      use autosquash formatted message to fixup specified commit
  •     –squash <commit>     use autosquash formatted message to squash specified commit
  •     –reset-author        the commit is authored by me now (used with -C/-c/–amend)
  •     -s, –signoff         add Signed-off-by:
  •     -t, –template <file>
  •                           use specified template file
  •     -e, –edit            force edit of commit
  •     –cleanup <default>   how to strip spaces and #comments from message
  •     –status              include status in commit message template
  •     -S, –gpg-sign[=<key-id>]
  •                           GPG sign commit

Commit contents options

  •     -a, –all             commit all changed files
  •     -i, –include         add specified files to index for commit
  •     –interactive         interactively add files
  •     -p, –patch           interactively add changes
  •     -o, –only            commit only specified files
  •     -n, –no-verify       bypass pre-commit and commit-msg hooks
  •     –dry-run             show what would be committed
  •     –short               show status concisely
  •     –branch              show branch information
  •     –porcelain           machine-readable output
  •     –long                show status in long format (default)
  •     -z, –null            terminate entries with NUL
  •     –amend               amend previous commit
  •     –no-post-rewrite     bypass post-rewrite hook
  •     -u, –untracked-files[=<mode>]
                              show untracked files, optional modes: all, normal, no. (Default: all)

git commit -m “Adding start.txt to demo our first commit”

  • [master 588d417] Adding start.txt to demo our first commit
    1 file changed, 1 insertion(+)
    create mode 100644 start.txt
    dhcp-10-159-135-46:github-demo jos$ git status
    On branch master
  • Your branch is ahead of ‘origin/master’ by 1 commit.
      (use “git push” to publish your local commits)
    nothing to commit, working tree clean

So now the changes (in this case just one file):

  • Has been moved from stage to the repository
  • We are notified that our local branch is ahead of origin/master by 1 commit
  • Our working tree is clean

Now let’s sync or local and remote repository with the push command:

  • git push origin master
    • origin : destination repository (in this case
      automatically configured when we used git clone command
    • master : destination branch
      as we mention at the begining, Git initializes the repository with just one branch named master


  • $git push origin master
    Counting objects: 3, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 342 bytes | 342.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
       504c785..588d417  master -> master

With this we complete the basics of a Git flow

Bonus, configuring textmate2 as default editor:

  • Install textmate2 (Mac)
    • Open preferences and install shell support
  • Now integrate it with Git:
    • $git config –global core.editor “mate -w”
    • $ git config –global -e
      This should open textmate

How to run Java in “unsafe” mode in Safari 11 ?

Unable to read a notification from SAT Buzon Tributario because you can’t sign it?

I was hitting this issue: received a notification from SAT (Mexico IRS) which as you can imagine may be a big deal, the problem is to read it you need to digitally sign it… and the app was not founding anything on my mac’s file system.

So after a while I realized it may be that Safari was blocking it… and yes it was, you need to run the site in “unsafe mode”

The problem is to do so you need to do an obscure (at least to me) Safari trick I found in this page:


Adding this post as it’s not obvious the relationshipt between SAT (Mexican IRS) and this security setting.

Solution in a nutshell:

  • Safari Preferences, Websites, Plug-ins, Java
  • Hold Alt (or Option), click the drop down menu next to the URL (, and select Run in Safe Mode.
  • Voila

UnsatisfiableError: The following specifications were found to be in conflict: keras pil

>conda install -c anaconda pil
Solving environment: failed

UnsatisfiableError: The following specifications were found to be in conflict:
– keras
– pil
Use “conda info <package>” to see the dependencies for each package.


Workaround: conda install pillow

“Pillow is the “friendly PIL fork” by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lundh and Contributors. ”

How to install Tensorflow in an Anaconda virtual environment – Mac

So I have Anaconda installed and wanted to install TensorFlow as well (I’m using PyCharm):

I tried installing TensorFlow with Conda as per official doc:

  • conda create -n tensorflow pip python=3.6
  • source activate tensorflow
  • pip install –ignore-installed –upgrade

However when creating a new virtual environment in PyCharm you need to make sure TensorFlow is installed as well in there, to do so simple do (after you have created your project {i.e. tf_basics} in PyCharm):

  • source activate tf_basics
  • pip install –ignore-installed –upgrade $URL_THAT_MAKES_SENSE I used:
    • pip install –ignore-installed –upgrade
    • Tip: you may get annoying messages like: “Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA”
    • Installing the proper tf version should fix it, take a look here for more info:
    • Or just do…
      import os
      os.environ[‘TF_CPP_MIN_LOG_LEVEL’] = ‘2’

To test your virtual env is running TensorFlow you can run TensorFlow hello world:

import tensorflow as tf
hello = tf.constant(‘Hello, TensorFlow!’)
sess = tf.Session()



How to add you xcode project to github

So you created a brand new xcode project and selected a local repository and are wondering how to add it to github?

Fear not, below steps to make it happen:


  1. Navigate to the path of your xcode project and run:
    git remote add foodTracker
  2. Pull the changes
    Git will complain of “fatal: refusing to merge unrelated histories”  solution”–allow-unrelated-histories” use the option
    git pull REPOSITORY master –allow-unrelated-histories
  3. Now you should be able to push from xcode

Other useful commands:

  • git show remote
  • git remote remove REPOSITORY

Happy coding!