Skip to content

Instantly share code, notes, and snippets.

@bernardobrezende
Last active April 10, 2017 18:35
Show Gist options
  • Save bernardobrezende/72b87d5cb1f79ae5607efd4cbe09d2c4 to your computer and use it in GitHub Desktop.
Save bernardobrezende/72b87d5cb1f79ae5607efd4cbe09d2c4 to your computer and use it in GitHub Desktop.
Utils

Disclaimer

⚠️⚠️⚠️

Use at your own peril

git

Recuperar stash perdido

git log --graph --oneline --decorate --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

Apagar branches já mergeadas

git branch --merged | egrep -v "(^\*|release)" | xargs git branch -d

Docker

Limpar arquivos desnecessarios

#!/bin/bash
# $ df -h
# $ du -a / | sort -n -r | head -n 10
# $ yum install jq
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v

# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi

# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
  docker ps -aq | xargs docker inspect | jq -r '.[] | .Mounts | .[] | .Name | select(.)'
) | xargs -r rm -fr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment