Updates were rejected because the tip of your current branch is behind

Github noob issue

My dashboard UI project is slow but going well. I am using this project as a way to improve my Github terminal skills and SCSS (frontend issues).

I kept running into this error message

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.

So dear future self here is the solution (and my shift key isn't working well so imagine my stress):

  1. git add .
  2. git commit -m "Useful commit message"
  3. git pull in my case that is git pull origin main and then push to sync the local and remote repository.
  4. git push origin main

That's how you solve it future self.