2

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
...
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
  • Could there be a case sensitive naming issue here with the branch in question? – Tim Biegeleisen Dec 11 '18 at 14:37
  • @TimBiegeleisen is not the case I do not know if Git save logs somewhere but I am pretty sure if it does I would be able to find when and how I delete that branch from the remote. – ReynierPM Dec 11 '18 at 14:44
  • Did you try to execute `git remote -v` ? What does it show ? – Djamel Dec 11 '18 at 14:57
  • @Djamel added to the OP :) – ReynierPM Dec 11 '18 at 15:00
  • And what about `git ls-remote --heads origin` ? – Djamel Dec 11 '18 at 15:05
  • @Djamel that shown all the remote branches the one that is giving me headaches isn't there though – ReynierPM Dec 11 '18 at 15:08
  • Indeed thats weird !! Have no idea sry – Djamel Dec 11 '18 at 15:08
  • 1
    Have you altered your `fetch` settings? (`git config --get-all remote.origin.fetch` will print them; the standard is `+refs/heads/*:refs/remotes/origin/*`.) Do you have a `core.fsmonitor` setting? – torek Dec 11 '18 at 16:46
  • @torek see my **update 2** in the OP, I haven't touch the `fetch` at all but for some reason besides the standard `+refs/heads/*:refs/remotes/origin/*` a lot of branches appear there, the problematic one included. Not sure how that went there. For the other setting I did run `git config --get-all core.fsmonitor` and it outputs nothing. – ReynierPM Dec 11 '18 at 18:01
  • OK, it's definitely the fetch setting. You can try ` git config --show-origin --get-all remote.origin.fetch`, which may tell you where the nonstandard entries are coming from (if your Git is new enough—show-origin was new in Git 2.8.0). – torek Dec 11 '18 at 18:30
  • @torek the command says it's coming from the `.git/config` file however, it's safe to remove all of them leaving only `fetch = +refs/heads/*:refs/remotes/origin/*`?? I did remove them just for try and the annoying message has disappeared. – ReynierPM Dec 11 '18 at 19:07
  • Yes, if they're in your private `.git/config` and you don't want them, you can remove them. The question becomes: who put them there? What were they trying to do? – torek Dec 11 '18 at 19:19
  • @torek by "they" you mean "me" because yes it's private and I have not a clue tbh – ReynierPM Dec 11 '18 at 19:33
  • If you want to remove the upstream information , just `git branch --unset-upstream `. And it's ok. And what is the result you expect? – einverne Dec 18 '18 at 09:01

1 Answers1

1

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 :

Cannabear
  • 76
  • 1
  • 8