Branch has TrackedBranch for non existent branch
See original GitHub issueLibGit2Sharp is reporting a tracked branch for a non-existent remote.
Output of git branch -a
branch-no-remote
master
* some-branch
remotes/origin/master
remotes/origin/some-branch
Here’s what libgit2sharp reports if I iterate through every branch in this repository and print out some properties:
---------------------------------------
CanonicalName: refs/heads/branch-no-remote
Tracked Branch: refs/remotes/origin/branch-no-remote
IsTracking: True
IsRemote: False
IsCurrentRepositoryHead: False
---------------------------------------
CanonicalName: refs/heads/master
Tracked Branch: refs/remotes/origin/master
IsTracking: True
IsRemote: False
IsCurrentRepositoryHead: False
---------------------------------------
CanonicalName: refs/heads/some-branch
Tracked Branch: refs/remotes/origin/some-branch
IsTracking: True
IsRemote: False
IsCurrentRepositoryHead: True
---------------------------------------
CanonicalName: refs/remotes/origin/master
Tracked Branch: (null)
IsTracking: False
IsRemote: True
IsCurrentRepositoryHead: False
---------------------------------------
CanonicalName: refs/remotes/origin/some-branch
Tracked Branch: (null)
IsTracking: False
IsRemote: True
IsCurrentRepositoryHead: False
Notice that refs/heads/branch-no-remote
is reporting a tracked branch of refs/remotes/origin/branch-no-remote
which does not exist in this repository.
Where’s it getting it? From the .git\config
I suppose.
[core]
bare = false
repositoryformatversion = 0
filemode = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://github.com/Haacked/publish-test.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "some-branch"]
remote = origin
merge = refs/heads/some-branch
[branch "branch-no-remote"]
remote = origin
merge = refs/heads/branch-no-remote
I suspect that libgit2sharp is using the branch remote info to populate the TrackedBranch
property. But it probably shouldn’t, right?
Issue Analytics
- State:
- Created 10 years ago
- Comments:17 (16 by maintainers)
Top Results From Across the Web
Is it possible to create branch that is tracking non-existing ...
This is a bash function that sets up a new local branch such that git push from that branch pushes to a new...
Read more >How can I tell a local branch to track a remote branch?
Let's talk about both the concept and the practice of "tracking" branches. ... Your local branch now has a "counterpart" on the remote...
Read more >I need to remove a remotely tracked branch that doesn't ...
The git fetch / git remote operation fetches the full current state of the remote repository into the remote tracking branches in your...
Read more >git pull from remote but no such ref was fetched?
It's possible that someone else on your team simply merged your branch and deleted it (commonly done after merging). You can make the...
Read more >Easily Perform Git Checkout Remote Branch [Step-by-Step]
Learn how perform Git checkout remote branch, effectively track remotes, and best practices to manage remotes and branches.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dahlbyk so what’s the cleanest way to determine if the
TrackingBranch
really is tracking something?branches[branch.TrackingBranch.Name] != null
I also got tripped up by this. What is the recommended way to check?
?
What do you think about adding an
IsGone
property toBranch
? That would use the same wording thatgit branch -vv
uses for gone branches:and devs would hopefully use that property before getting tripped up by
TrackedBranch