Skip to content

Instantly share code, notes, and snippets.

View mosra's full-sized avatar

Vladimír Vondruš mosra

View GitHub Profile
@mosra
mosra / README.md
Last active October 10, 2023 19:58 — forked from ColCh/README.md
Git pre-push hook to confirm pushing to master

Git pre-push hook

Checks if the remote branch is master, then asks a confirmation. Based on https://gist.github.com/ColCh/9d48693276aac50cac37a9fce23f9bda, but modified to check the remote name instead of local, making it work also for the really dangerous accidents like below:

git push -f origin e09b7418a310114f6aaf495f969c3859095a99af:master

Further info: https://dev.ghost.org/prevent-master-push/, https://coderwall.com/p/jp7d5q/create-a-global-git-commit-hook, https://git-scm.com/docs/githooks#_pre_push, https://stackoverflow.com/questions/22585091/git-hooks-pre-push-script-does-not-receive-input-via-stdin

@mosra
mosra / bt.sh
Last active April 24, 2024 17:52
Print a backtrace of the last failed command
#!/bin/bash
# Save into /usr/local/bin/bt and make the file executable.
#
# Calling `bt` then non-interactively prints a backtrace of last program that
# exited with a SIGABRT or SIGSEGV. Makes use of systemd's builtin coredumpctl,
# causes no core files littered around on the filesystem.
set -e
coredumpctl debug -q -A "-iex \"set pagination off\" -iex \"set style enabled on\" -iex \"set debuginfod enabled on\" -ex bt --batch"