1

I simply cloned a repo, then performed git fetch. I haven't created any branches, nothing is tracked. When I type "git branch" it shows (besides "master") a hundreds of remote branches in the form: /Dev/Project/<sth>. The heads subdirectory is empty. I always thought that git branch shows only local branches by default and always. And this is true for other, similar projects. from the same server. So why I see them all in this particular case? And how to get rid of all of them?

update: These unwanted branches appear in .git/refs/remotes/<remotename>. But the funny thing is that I see more branches in this location. Some of them don't appear in git branch output (expected), only ones that start with /Dev or /Feature pollute the console. I cannot recognize any rule for it.

update: Now i see that git fetch creates these unwanted branches locally:

* [new branch] Dev/... -> remotename/Dev/...

Why? I don't see any option to prevent git fetch from doing it.

update: Config for remote that pollutes is as follows (I think it is correct):

[remote "BB"]
    url = ssh://.....
    fetch = +refs/heads/*:refs/remotes/BB/*

update: My global git configuration:

push.default=upstream
push.followtags=true
user.name=me
user.email=me@mycompany.com
merge.ff=false
core.filemode=false
core.autocrlf=input
core.trustctime=false
pull.rebase=true
pull.ff=true
diff.tool=meld
ardabro
  • 1,907
  • 16
  • 31
  • Sounds like the contributors to this repo have created branches outside the normal `refs/heads/` directory. You may want to let them know about it. This may be relevant: https://stackoverflow.com/a/26047558/2541573 – jub0bs Sep 24 '18 at 08:58
  • I realized that I see them all in "/refs/remotes//Dev/...". Seems correct, but I see only some (the most) of them in bit branch output. – ardabro Sep 24 '18 at 11:27
  • 1
    If the output of `git branch -a` isn't sensitive, could you paste it in your question? – jub0bs Sep 24 '18 at 11:40
  • Actually it sensitive, but I can provide additional info: in `git branch -a` output normal remotes appear as `remotes//` while these polluting ones appear (only) with pattern `Dev/` or `Feature/` as they were local. – ardabro Sep 24 '18 at 11:58
  • 3
    I'm not sure what's going on here, but it's worth pointing out that *all* references are local, including remote-tracking names, and `git fetch` obeys your `remote..fetch` line when creating `refs/remote//Dev/` from `refs/heads/Dev/`. Do you have an unusual `fetch` setting? (This could come from `.git/config` or from your global or `--system` configuration.) – torek Sep 24 '18 at 15:26
  • I know it but the problem is that git creates unwanted local branches during fetch. I'm able to delete them manually, but it is workaround - not the solution. my remote configuration looks OK (see last update). – ardabro Sep 25 '18 at 10:23
  • The only ay I know to get the behavior you're describing is to override the factory default refspec, there's lots of ways to do it, on the command line or in a template config used by clone or in the little-used site config. Clone itself does a fetch with the default specs, and you're showing the factory defaults, so the one you did manually should have had no effect at all. The behavior you describe is not normal. There's something material in your command sequence or configuration you're not showing us. – jthill Sep 25 '18 at 10:44

0 Answers0