Git: Your branch is based on 'origin/branch', but the upstream is gone.

Since I've added remote branch on my local repository, and when I'm going to checking out a remote branch, I got an error/warning message like the title of this post above. After googling same keywords of the warning message, there was who asked on stackoverflow with the same error message like me.

$ git checkout apps-devel
Checking out files: 100% (208/208), done.
Switched to branch 'apps-devel'
Your branch is based on 'hsp/apps-Dev', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

For your information, the original remote branch is hsp/apps-Dev and I've rename it to apps-devel. I try to pull a remote branch as well, and get another message like below:
$ git pull hsp
Your configuration specifies to merge with the ref 'refs/heads/apps-Dev'
from the remote, but no such ref was fetched.

So this is how to fix it.
First open the git config on your local repo (generally the location at .git/config). Here are my configs for the remote branch:
[branch "apps-devel"]
 remote = hsp
 merge = refs/heads/apps-Dev

and I change it to
[branch "apps-devel"]
 remote = hsp
 merge = refs/heads/apps-devel

Then let's checking it again
$ git pull hsp
Already up-to-date.

$ git status
On branch apps-devel
Your branch is up-to-date with 'hsp/apps-devel'.

nothing to commit, working tree clean

As you can see above, no warning message anymore.

Happy Independence day Indonesia! 🇮🇩
Hiduplah Indonesia Raya
🇮🇩

Leave a Reply

Please leave a comment and do not give a spam! Comments that smells of spam will be deleted without prior notice