Some Snippets and Commands!

Hello there. Not much here, just a collection of useful commands and code snippets that have slipped my mind.

typescript
## Github Commands
# reset the last commit locally
git reset HEAD~
# squash last commit with new changes
git add .
git commit --amend --no-edit
git push origin -f <branch>
# rebase
git pull --rebase origin develop
git push origin -f <branch>
# unknown conflicts
git pull --rebase origin master
git checkout origin/master -- yarn.lock
git rebase --continue
yarn install
git commit -m "new changes"
git push origin -f <branch>
# squash multiple commits together
git rebase --root -i
use squash > exit
git push -f origin main
# tagging
git tag "v1.0.0"
git push origin "v1.0.0"
typescript
## Docker Commands
# Containers
- `docker ps` - all running containers
- `docker ps -a` - all conatianers
- `docker run` - start a new container ( create a new )
- `--name` - add a name to container
- `-d` - run in detached mode
- `--rm` - remove container after stop
- `docker attach <id>` - attach again
- `docker logs <id>` - logs
- `docker logs -f <id>` - keep on logging
- `-p 3000:80` - export a port
- `docker start` - restart a stopped container
- `docker start -a` - start in attach mode
- `docker rm` - remove container
- `docker stop` - stop container
- `docker cp test/. container:/test` - copy to container
# Images
- `docker images` - view all images
- `docker build` - build an image
- `-t` - tag an image
- `docker rmi` - delete images
- `docker image inspect` - inspect image
- `push` - push a docker image
# Volumes
- `docker run -v` - create a volume
- `-v /app/data` - anonymous volume
- `-v data:/app/data` - named volume
- `-v /path/to/code:/app/code` - bind mounts
- `docker volume ls -q -f dangling=true` - remove dangling images
# Networking
- `host.docker.internal` - connect to host
- `docker network create` - create a docker network
- `--network` - create a network
# Docker Compose
- `--build` : rebuild images