ReynierPM
ReynierPM

Reputation: 18690

How to remove a remote reference in Git?

I am having a "weird" issue probably because I did something wrong or forgot to do something else but now each time I run the following command:

git checkout master && git pull origin master && git fetch -p

I got the following error:

Already on 'master'
From ssh://reponame
 * branch                  master     -> FETCH_HEAD
Already up to date.
fatal: Couldn't find remote ref refs/heads/global/CDP-5353_fix

I have tried the following (that I got from here):

E:\repo (master -> origin)
λ git branch -r | grep CDP-5353_fix

E:\repo (master -> origin)
λ git branch | grep CDP-5353_fix

Branch CDP-5353_fix does not exists locally and/or remote.

E:\repo (master -> origin)
λ git branch --unset-upstream

E:\repo (master -> origin)
λ git checkout master && git pull origin master && git fetch -p
Already on 'master'
From ssh://reponame
 * branch                  master     -> FETCH_HEAD
Already up to date.
fatal: Couldn't find remote ref refs/heads/global/CDP-5353_fix

Same issue ...

E:\repo (master -> origin)
λ git branch -d -r origin CDP-5353_fix
error: remote-tracking branch 'origin' not found.
error: remote-tracking branch 'CDP-5353_fix' not found.

E:\repo (master -> origin)
λ git config --unset branch.CDP-5353_fix.remote

E:\repo (master -> origin)
λ git config --unset branch.CDP-5353_fix.merge

E:\repo (master -> origin)
λ git checkout master && git pull origin master && git fetch -p
Already on 'master'
From ssh://reponame
 * branch                  master     -> FETCH_HEAD
Already up to date.
fatal: Couldn't find remote ref refs/heads/global/CDP-5353_fix

Same issue ...

What I am missing here? The message is not messing up with my repo or anything on it but it is annoying. Any help?

UPDATE 1:

Output of git remote -v:

λ git remote -v                                           
origin  ssh://reponame (fetch) 
origin  ssh://reponame (push)  

Note: I am hiding the real repo name because it belongs to the company I work for and they don't like to share that kind of stuff.

UPDATE 2:

Output of git config --get-all remote.origin.fetch:

λ git config --get-all remote.origin.fetch
+refs/heads/*:refs/remotes/origin/*
+refs/heads/CDP-5288:refs/remotes/origin/CDP-5288
+refs/heads/CDP-5299:refs/remotes/origin/CDP-5299
+refs/heads/global/CDP-5353_fix:refs/remotes/origin/global/CDP-5353_fix
...

Upvotes: 3

Views: 4262

Answers (1)

Cannabear
Cannabear

Reputation: 76

I wanted to post it as a comment but seems like i'm too much of a newbie on StackOverflow to do so.

The list of branches in your .gitconfig file are all the remote branches you have ever checkout to.
It is fully automatic and does not need human intervention.

In fact, it allows to set for example multiple branches to push to or merge from your branch.

A really good explanation is given in this other post :

Upvotes: 1

Related Questions