Git: upstream is gone

I came across a git repo recently that output this message with every operation I did:

Your branch is based on 'origin/master', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

I was delivering a workshop at the time so I kinda snarled at it and carried on with what I was doing, but later I looked up what is happening. This occurs when a branch is tracking a branch that the git repo doesn’t have any information about – the branches to be tracked aren’t in the local repo metadata.

In my case, it happened because I had created and then cloned an empty repo for training purposes – so origin/master didn’t actually exist yet! I added a quick commit-and-push to my script and hope that I won’t be upstaged by this change that came in with git 1.8.5.

Hopefully this post will help someone else to avoid being upstaged or irritated by this as well!

7 thoughts on “Git: upstream is gone

  1. “I added a quick commit-and-push to my script…” I did this and nothing happened. I got an message:
    No refs in common and none specified; doing nothing.
    Perhaps you should specify a branch such as ‘master’.
    Everything up-to-date

    googled this . still no beginner level answer.

    • Let me see if I can make this a bit clearer. When I saw this message, it was because I had cloned an empty repository. To fix it, I added one commit to my current master branch, then pushed the changes. My local branch was tracking the remote one as is the default behaviour after a fresh clone. Hope that helps!

  2. If you don’t have files to add, you can also do the following
    [code]
    git branch –unset-upstream
    get push –set-upstream origin master
    [/code]
    Works for me using BitBucket

  3. Absolute help!
    I tried pruning a renamed branch, everything was a mess, but “git branch –unset-upstream” was the only thing I needed to do.
    Thanks for the tip!

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)