git fetch failed "refs/remotes/origin/pr/34 tracks both"
git
Solution
Short version: the branch named `pr/34` on the remote, becomes your `origin/pr/34`. But the ref named `refs/pull/34/head` on the remote, also becomes your `origin/pr/34`. But they can't both become that, so git complains and quits. Whatever is setting up the branch mapping is not playing well with whatever is setting up the pull-request branches on github (but I don't know anything about those two pieces of software).
It may (I don't know) be reasonable to delete the `+refs/pull/*/head:refs/remotes/origin/pr/*` `fetch` configuration line. Alternatively, you could map these to some other local ref-name-space, such as `refs/pullreqs/origin/*` (but such a reference name is somewhat inconvenient to type in). If every pull request is going to create both `refs/heads/pr/number` and `refs/pull/number/head` on github, I'd go ahead and remove the one configuration line.
Longer explanation of source of problem follows. Given this:
+refs/pull/*/head:refs/remotes/origin/pr/*
+refs/heads/*:refs/remotes/origin/*
+refs/heads/*:refs/remotes/origin/*
as output from `git config --get-all remote.origin.fetch`, I can explain what's going wrong. "How to fix it" depends on the results you want.
Each output line here is a "refspec", which consists of three parts: the `+`, a name on the left of the `:`, and a name on the right of the `:`. One `*` is allowed in both names, and it works sort of (but not exactly) like `*` matching in file-names, e.g., `*.c`, `*.py`, etc., with the second `*` then using whatever the first `*` matched. It should be obvious below, anyway.
(The last line is redundant and thus harmless, it just makes the match happen twice.)
So, let's see what the above means for the ref-names `refs/pull/34/head` and `refs/heads/pr/34`, both of which are present in the remote named `origin` (on github).
For `refs/pull/34/head`: this matches just the first refspec. The `*` part matches the `34`. The right-hand-side of that refspec says to rewrite this to read `refs/remotes/origin/pr/*`, so the result is:
refs/remotes/origin/pr/34
Now let's tackle `refs/heads/pr/34`. This does not match the first refspec, but it does match the second. The `*` part matches `pr/34`. The right-hand-side of that refspec says to rewrite it as `refs/remotes/origin/*`, so the result is:
refs/remotes/origin/pr/34
Note how two different names on `origin` have mapped to the same final name in your local repository. Git does not know whether to set your local `refs/remotes/origin/pr/34` equal to the first one, or the second one, as seen on `origin`.
To make the error go away, you must either discard the unwanted "extra" match entirely, or change the rewriting rules so that the two different remote `refs/whatever`s become two different local `refs/remotes/origin/whatever`s. That means you need to change the `fetch =` lines in your git config file.
I don't know what result you want, so I can't say how to rewrite them. (And, I don't know what created these in the first place—a normal `git clone` creates just one `+refs/heads/*:refs/remotes/origin/*` entry. Something else added the redundant entry, and the one for `refs/pull/*/head`. It's that something-else that broke things. Well, that, plus the fact that something created `refs/heads/pr/34` on github.)
Problem
I am new to git and I am stuck on a git fetch (I have more experience on TFS & SVN, so any analogy is welcome :) So I found a project on Github that I forked : - source project (Xposed Tinted StatusBar) - mine is here I made a few check-in, also made a git pull to fetch latest changes from the source and at some point, I think I hit the Synchronize button (I'm using the AndroidStudio BTW) and I got lost from here. It generated this commit that I don't really understand and from here, it seems that I am not able to fetch latest additions from source anymore (the 4 last changes on black source) I am getting the following error on git fetch : fatal: refs/remotes/origin/pr/34 tracks both refs/pull/34/head and refs/heads/pr/34 https://github.com/MohammadAG/Xposed-Tinted-Status-Bar/network Thanks