Commands Worth Noting

git log --oneline

  • Clean one line input in the form [hash] [message]

git log --pretty-format:"%an <%ae>"

  • Displays username and email of each commit

git push -u origin main

  • -u effectively creates a binding with the remote repo; meaning that you only have to type git push next time you want to push.

git push --force origin [remote-branch]

  • Overides all commits of remote/up-stream repo with ones from local repo.

git remote set-url origin [url]

  • Update/set a new url of remote repo.

git rm -r --cached <directory_name>/

  • Used to untrack a file after a .gitignore is set, because anything before that will be tracked.

git add .; git commit -amend

  • To commit current changes as part of last commit. Save and close editor after changing (or not changing) the last commit message.