# Quick Reference

# Programming

# Quick Git Commands

Remove merged branches

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

<p class="callout warning">Make sure to test the first command before running the whole line, you don't want to accidentally delete your main branch</p>

Prune local branches that are deleted on the remote

```bash
git fetch --prune
```

Properly delete a remote branch

```bash
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

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

```

<p class="callout info">Be sure to use ^\] instead of exiting the shell directly - this command spawns a service that will fail if exited improperly</p>