I have a fork of a Git repo and my clone appears to have an issue with an old, no longer existant, branch. I keep seeing this message:
error: refs/heads/t_1140
I'm giving my two cents for whoever is using Visual Studio. I had this issue while trying to delete a local branch and running the following command through the command line solved it:
git branch -D <branchName>
Check .git/refs/remotes/origin
. They are there and the upstream no longer has them. To clean out the remotes that no longer exist run
git remote prune origin
You could also see what it would to by adding --dry-run
before actually doing it.
If it's failing with this:
error: failed to run repack
Look in .git/packed-refs
for the listed branch(es) and remove those lines. I tried all the other solutions, but this finally solved it for me.
After trying various solutions, I finally got the references cleaned up on Windows command prompt with the following:
for /f %i in ('git for-each-ref --format="%(refname)"') do git show-ref --quiet --verify %i || git update-ref -d %i
I had this issue when attempting to clone some github repositories, the system I was on was running an older version of git v1.7.4
, a quick update fixed it up.
remote: Counting objects: 533, done.
remote: Compressing objects: 100% (248/248), done.
remote: Total 533 (delta 232), reused 529 (delta 230)
Receiving objects: 100% (533/533), 121.36 KiB, done.
Resolving deltas: 100% (232/232), done.
error: refs/remotes/origin/master does not point to a valid object!
verror: Trying to write ref refs/heads/master with nonexistant object 0457f3e2e9432e07a1005f0f4161dc4b8215f128
fatal: Cannot update the ref 'HEAD'.
You say that you have:
also checked .git/refs/heads and there's no reference to t_1140
... which is very surprising. I can only see how this error would occur if the file .git/refs/heads/t_1140
exists. Is it possible you were mistaken about this?
Correction: Charles Bailey points out below that the refs might be packed, in which case there is no corresponding file in .git/refs/heads