Git & Docker cheatsheet - FHNW-IGEO/Geoharvester GitHub Wiki

While Docker can be managed by Docker Desktop in Windows, Ubuntu or VSCode might require the use of a command line. For interacting with the production EC2 instance, you probably need the command line as well.

Docker

Run from location of docker files (/server in our case)

  • docker compose up --build - (Re)build your container and start it. Don't use the old docker-compose (with hyphen). CTRL + C to stop process.
  • docker compose down - Stops the container. Usually exciting the process is good enough.

Global commands:

  • docker ps - Check what containers are running. In our case it should be two (redis and fastapi). If container is unhealty you see it here.
  • docker system prune - (also "container" or "images" instead of system). Throw away old images etc. Good practice to do once in a while to clean up your system & free up space
  • docker logs <containername> - See the logs of a container. Get containername from docker ps

Git

Branches:

  • git remote -v - Check which repository is your "origin". Should point to [email protected]:FHNW-IVGI/Geoharvester.git
  • git branch- Check which branch your on
  • git fetch- Get branches from remote. You might need to use this to check out the latest stuff
  • git checkout <branchname> - Set your branch to be the one specified. Needs existing branch(name)
  • git checkout -b <branchname> - Create and checkout a new branch with (branchname).

Status:

  • git status- Check if you have uncommited file changes
  • git log - Check the logs of your commits
  • git stash - Save uncommited changes to a "cache", e.g. to discard them when experimenting or when you need to switch your branch for a second. Not for permanent saving!
  • git stash pop- Get your changes back after a git stash

Changes:

  • git add <filename> - Add a single file to staging
  • git add . - Add all modified files to staging. Don`t use this by default, as it is good practice to conciously verify your changes.
  • git commit -m- Commit your staged files. Please use a meaningful commit message, as it helps you and others when checking logs etc.
  • git push - Push changes to repo. First push the console will require you to link to repo, just copy & paste the suggestion from the terminal
⚠️ **GitHub.com Fallback** ⚠️