Some useful Git commands, some of them for regular use but most you just need every once in a while. Here is where I remember them.
Checkout a file from another branch
git checkout master ./path-to-filePassing a file path to the checkout command checks out only that file from the branch specified. This is mostly useful to clean up messes.
Delete merged branches locally
git fetch --pruneUseful when doing some housekeeping.
Checkout the previously checked out branch
git checkout -Quickly navigate between branches.
Connect a local branch to a remote branch
git branch --set-upstream-to=origin/foo fooThis becomes necessary from time to time. You can also use -u= instead of --set-upstream-to=.
Change the remote
git remote set-url <name> <new-url>Necessary after migrating a repo, i. e. to a new host or if a fork upstream has changed.