Cheat sheet
This is a collection of commands I use fairly regularly, but sometimes forget.
Table of Contents
Docker
- Delete all not running containers
docker rm $(docker ps -q -a)
- Delete all running containers
docker rm -f $(docker ps -q -a)
- Delete all images
docker rmi -f $(docker images -q -a)
- Delete dangling volumes and images
docker volume rm $(docker volume ls -q -f "dangling=true") ; docker rmi $(docker images -q -f "dangling=true")
Modify a commit in git history
Suppose:
- HEAD
- f673769
- 5b5a808
- cf08425
- To modify
5b5a808
, run:git rebase --interactive 5b5a808^
- Edit the line with the commit you want to change from
pick
toedit
- Do your changes, add your changes and amend the commit:
git commit --all --amend
- Continue rebase:
git rebase --continue
git
# Change comment char so gitlab issues can be referenced in commit messages
git config --global core.commentchar ";"
# Auto --prune on pull or fetch
git config --global fetch.prune true
# Aliases
git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
Aliases
# Remove branches that don't have a remote tracking branch
alias git-remove-branch='git branch -d $(git branch --merged master | grep -v "^[ *]*master")'