title: "Git: fatal: bad object refs/remotes/origin/mybranch" after pressing the "Sync Changes button" in VSCode
body: <p>I am new to using Git and GitHub, so please forgive me if the solution is really simple.</p>
  <h2>Context</h2>
  <p>In Visual Studio Code, there is a button, that appears when you have changes in your local repository that haven't been pushed to the remote repository, that says &quot;Sync Changes&quot;. This button can be found in the source control panel which can be accessed by pressing <code>CTRL + SHIFT + G</code> on Windows. What this button does is that it just pushes any new commits to the remote repository and pulls any changes in the remote repository over to your local repository.</p>
  <p>This button is very useful when I want to push any new commits over to GitHub without having to open up the terminal.</p>
  <h2>The Problem</h2>
  <p>Most of the time, this button works. However, sometimes it just opens a popup saying <code>Git: fatal: bad object refs/remotes/origin/mybranch</code> and doesn't actually push my changes. If I try again, it gives me the same popup. When it does happen, I usually just delete the local repository and then clone the remote repository from GitHub, but that's really annoying to do.</p>
  <h2>When Does This Happen</h2>
  <p>This phenomenon seems to happen after switching to my main branch using <code>git checkout main</code>.</p>
  <hr />
  <p>For now, I am just going to push any new commits by using the command <code>git push -u origin</code>, but I do hope that someone will come and show me how to make the button actually work as the button is very convenient.</p>
  <p>As I have said, I am sorry if the solution is very simple. I am new the Git and GitHub.</p>