contrarian notes on software engineering, Open Source hacking, cryptocurrencies etc.

git alias to “make a single commit reverting to previous commit”

make-a-big-revert-to = "!f() { \
     ts=`date +"%Y%m%dT%H%M%S"`; \
     tmp_branch="_make-a-big-revert-to-`date +"%Y%m%dT%H%M%S"`"; \
     git diff-index --quiet HEAD || { echo "Not clean"; exit 1; }; \
     git branch ${tmp_branch}; \
     git reset --hard ${1}; \
     git submodule update --init --recursive; \
     git reset --soft ${tmp_branch}; \
     git branch -D ${tmp_branch}; \
     shift; \
     git commit -a --no-verify "$@"; \
  }; f"

Based on an answer to “Revert to a commit by a SHA hash in Git?”