Some Snippets and Commands!
Hello there. Not much here, just a collection of useful commands and code snippets that have slipped my mind.
## Github Commands# reset the last commit locallygit reset HEAD~# squash last commit with new changesgit add .git commit --amend --no-editgit push origin -f <branch># rebasegit pull --rebase origin developgit push origin -f <branch># unknown conflictsgit pull --rebase origin mastergit checkout origin/master -- yarn.lockgit rebase --continueyarn installgit commit -m "new changes"git push origin -f <branch># squash multiple commits togethergit rebase --root -iuse squash > exitgit push -f origin main# tagginggit tag "v1.0.0"git push origin "v1.0.0"
## 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