For some reason my git log shows that I have a fork/main branch, like so:
~ git log
commit abc123abc123 (HEAD -> main, origin/main, origin/HEAD)
Author: Me
...
commit xyz789xyz789 (fork/main)
Author: Me
...
But locally, I only have 1 branch (main), and on my private github repo, Forks shows 0. What is this thing and how do i get rid of it / understand it?
Probably related but when i do gh pr create, it offers me my repo as an option twice. This doesnt happen with my other private repos:
? Where should we push the 'testing' branch? [Use arrows to move, type to filter]
> me/my-private-repo
me/my-private-repo
Skip pushing the branch
Cancel
UPDATE:
~ git remote -vv
fork https://github.com/me/my-repo.git (fetch)
fork https://github.com/me/my-repo.git (push)
origin https://github.com/me/my-repos-old-name.git (fetch)
origin https://github.com/me/my-repos-old-name.git (push)
~ git branch -r
fork/fix-types <--- This PR was recently landed and the branch deleted, but never on any kind of fork (at least not that i know of)
fork/main
origin/HEAD -> origin/main
origin/main
The output of git remote -vv and the fact that you say you renamed your repo on GitHub is saying that fork is simply your local name for the remote with the new URL, and origin is your local name for the remote with the old URL.
From your commit log, it looks like you're still pushing using the old name, but that doesn't matter, because GitHub keeps the old name around as an alias whenever you rename a repo. That's to keep old sandboxes working.
There isn't actually a problem in all this, you could ignore it and keep going with pushing to origin using the old URL. But if you want to clean it up so it's less confusing, you can 1) remove the unnecessary fork remote, and 2) change the URL for origin.
Run
git remote remove fork
to remove the fork remote from your sandbox.
I think it's worth doing this, because the presence of this supposed (misnamed) fork in the logs will indeed continue to be confusing.
Run
git remote set-url origin https://github.com/me/my-repo.git
to make origin point to the new URL instead of the old one.
This is just for tidiness, but it will make no effective difference, since GitHub will keep the old name around forever (well, as long as you don't re-create a new repo with the old name later) as a redirect to the new name. But it will make things clearer in the future, and I guess it avoids using the redirect so it might be (a tiny bit) more efficient.
Probably related but when i do gh pr create, it offers me my repo as an option twice
Note that you won't see that anymore with [gh CLIv2.71.0] (https://github.com/cli/cli/releases/tag/v2.71.0) (Apr. 2025)
From PR 10513, the command gh pr create now supports Git's @{push} revision syntax for determining head ref.
Meaning, even before you have remove/renamed your fork, a gh pr create would directly create the PR, without asking you "Where should we push" anymore, which means you would no longer see those repo options twice.
In your case, a git remote rename fork origin remains the safe route.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With