Git Commands

This section focuses on different git commands and their most common or useful options, as child pages. However there are some extra notes here as well.

Useful Commands

git checkout ./dir/filename.ext - this is a handy way to undo local changes on a specific file, provided the changes have not been committed
git reset --hard - this undoes all local uncommitted changes, removing any extra files
git bisect - used when you need to find when a bug or change was introduced
git remote -v - shows the remote repositories
git clone https://github.com/xxxx/yyyy.git newdir - clone code to "newdir" instead of "yyyy"
git pull --rebase origin master - you need all changes in commits, but this will revert your commits, apply all the missing commits from the remote master and then re-apply your commits, very useful for bringing a branch up to do ready to merge it, but note, your commit ids will change
git shortlog -10 - see who did the last 10 commits
git rev-parse HEAD - show the latest commit id, useful for scripts etc
git rev-parse origin/main - show the latest commit id on the server's main branch
git show <commit-id> - show the commit details for the specified commit-id