Setting an upstream branch can be useful, it tracks if you are commits behind or ahead and you can run
git push without the need to specify a remote and branch. However, there might be a place and time where you rather undo this branch tracking. The
branch subcommand in git has an option to unset the upstream branch, which you use to stop tracking the remote branch. The command is used as follows:
$ git branch --unset-upstream [<branchname>]
In practice that would look like the following:
$ git branch --unset-upstream main
Keep in mind that you specify the local branch and not the remote branch, so in this case
main instead of
origin/main. Which makes sense because we are detaching the local branch from its remote, not the remote branch from our local branch. The remote repository is completely unaware of the fact that you are locally tracking some of its branches.
You can run the command without specifying a branch name as well. In that case git assumes that you want to stop tracking a remote for your currently active branch.
$ git branch --unset-upstream