0

I decided to remove the upstream remote reference from my local repository, but git-branch keeps showing remotes/upstream/master. I pruned the references, but it keeps showing upstream. How do I clean it properly?


Here is what I had, what I did, and what I have:

Fetching from upstream was broken, that's why I decided to remove upstream (since I'm not using it anyways):

git fetch --all Fetching origin remote: Enumerating objects: 9, done. remote: Counting objects: 100% (9/9), done. remote: Compressing objects: 100% (5/5), done. remote: Total 9 (delta 4), reused 8 (delta 4), pack-reused 0 Unpacking objects: 100% (9/9), done. From github.com:dockerstuff/docker-jupyterhub-deploy a977d21..7393fc7 master -> origin/master Fetching upstream fatal: couldn't find remote ref refs/heads/master error: Could not fetch upstream 
$ git remote -v origin [email protected]:dockerstuff/docker-jupyterhub-deploy (fetch) origin [email protected]:dockerstuff/docker-jupyterhub-deploy (push) upstream https://github.com/jupyterhub/jupyterhub-deploy-docker.git (fetch) upstream https://github.com/jupyterhub/jupyterhub-deploy-docker.git (push) 
$ git branch --all * master remotes/origin/HEAD -> origin/master remotes/origin/master remotes/upstream/master 
$ git remote remove upstream 
$ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master remotes/upstream/master 
$ git fetch -p --all Fetching origin 
$ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master remotes/upstream/master 
git remote -v origin [email protected]:dockerstuff/docker-jupyterhub-deploy (fetch) origin [email protected]:dockerstuff/docker-jupyterhub-deploy (push) 
$ git remote prune upstream fatal: 'upstream' does not appear to be a git repository fatal: Could not read from remote repository. 
$ git remote prune origin 
git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master remotes/upstream/master 

Why is remote/upstram/master still there?

3
  • 1
    The title says origin but your question uses upstream? Commented Oct 9, 2023 at 17:55
  • stackoverflow.com/… Commented Oct 9, 2023 at 18:36
  • 1
    git branch -r -d upstram/master Commented Oct 9, 2023 at 18:37

1 Answer 1

3

This is because the git branch -a command lists both local and remote branches.

The remotes/upstream/master branch you see is a remote tracking branch that is stored locally to keep track of the state of the upstream repository.

Try this once :

git branch -d -r upstream/master 

After that if you run git branch -a again, you can check if the remotes/upstream/master branch is no longer listed.

Please let me know if you still issues.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.