update

alias update='git fetch origin && git merge orgin/main'

don’t commit to main

Important for working with a team where everyone works on the same repo and has dev branches.

Add a new pre-commit hook in your repo.

# .git/hooks/pre-commit
#!/bin/sh

branch="$(git rev-parse --abbrev-ref HEAD)"

if [ "$branch" = "main" ]; then
  echo "You are on branch $branch. Commits directly to this branch are not allowed."
  exit 1
fi

unstage a file

git restore --staged some-file.py