Monday, 10 October 2016

Git repo that tracks only the head commit of a branch

Quick note to self on how to have a git repo that only contains a single commit, the head of a branch.

Initiate it with:

git clone <url> --branch <branch_name> --depth=1

Update it with:

git pull && git pull --depth=1 && git reflog expire --expire-unreachable=now --all


  1. Thanks for sharing the direct code it will come in handy but I would appreciate if could just add some description aswell. It will be easy for the non IT literates.

  2. I have been meaning to write something like this on my website and you have given me an idea. tik tok video