My CLI cheat-sheet

Photo by David Travis on Unsplash

There are some things that can be useful to me, but I totally keep forgetting the syntax. Well, not any longer!




# display branching tree
git log --graph --full-history --all --pretty=format:"%h%x09%d%x20%s";
git log --graph --decorate --oneline;
# display history of commits for a specific branch
git log --walk-reflogs master;
# un-stage all uncommitted changes
git reset HEAD
# un-stage all uncommitted changes and erase them
git reset HEAD --hard
# remove un-tracked files
git clean -fd
git clean -fX

Work with tags

# get all remote tags
git fetch --all --tags;
# kill remote tag
git push --delete origin v1.2.0;
# kill local tag
git tag -d v1.2.0;


# parametrized alias
alias dssh='function __sampleAlias(){ docker exec -it $1 /bin/bash; };__sampleAlias';
# launch chrome from the command line in Mac
alias chrome="/Applications/Google\\ \\\\ \\Chrome";
# get console command by its PID
ps -p [PID] -o args;


# make a total package upgrade
yarn upgrade <package-name> --major
# find out why the package was installed
yarn why <package-name>
# get the latest version of a package that exists on NPM
yarn info <package-name> | grep version:


# remove all exited containers
docker rm $(docker ps -a -f status=exited -q)
# remove all working containers
docker rm $(docker ps -a -q)
# remove all images
docker rmi $(docker images -a -q)
# remove volumes, networks
docker system prune

To be continued...

Sergei Gannochenko

Business-oriented fullstack engineer, in ❤️ with Tech.
JS / JS stack: React, Node, Docker, AWS.
15+ years in dev.