Git Tricks

Here are some tricks that I use. They’re here because I need a place to quickly refer to them.

  • Updating a fork with upstream changes:
  • Interactive rebasing:
    • git rebase -i <branch>
  • To avoid messing up a PR, you can do things like:
    • git reset –hard HEAD-1 # or HEAD-2, etc, or directly to a commit hash
    • git push –force origin branch_name
  • Always do a backup before reset or rebase