How to revert a single file to its state in main in branch

I want to reset a file stored in a git repo to its state as the main branch, and I kept forgetting how to do this. So here is how, just to remind my future self. ➜ git status On branch main Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: kube-prometheus-stack-values.yaml no changes added to commit (use "git add" and/or "git commit -a") The above output shows that there is a modified file, kube-prometheus-stack-values.yaml that is not yet staged for commit. ...

February 28, 2025 · 1 min · 157 words · kenno