Useful Git Techniques

Refresh the local main branch from remote/origin/main when you're not currently on main

git fetch origin main:main

Refresh the current branch from the local main branch

git merge main --no-edit

From Geoff Rich on Mastodon.

Force a pull to overwrite your local files

git fetch --all
git reset --hard <remote_name>/<branch_name>

Delete a local, not current, branch

git branch -d <branch_name>

The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet.

Delete a remote branch

git push <remote_name> --delete <branch_name>

Rename or change the case of a file

git mv -f application.cfc Application.cfc