Quick Reference

Programming

Programming

Quick Git Commands

Remove merged branches

git branch --merged origin/main | rg -v "main" | xargs git branch -d

Make sure to test the first command before running the whole line, you don't want to accidentally delete your main branch

Prune local branches that are deleted on the remote

git fetch --prune

Properly delete a remote branch

git push origin delete <remote name> <branch>

Source: https://www.freecodecamp.org/news/git-delete-remote-branch/

systemd Shell Execution

To start a shell with the same environment as a particular systemd service

sudo systemd-run --property=EnvironmentFile=<path/to/env/file> --uid=<service user> --pty bash

Be sure to use ^] instead of exiting the shell directly - this command spawns a service that will fail if exited improperly