Daniel Moss Daniel Moss - 1 year ago 252
Git Question

Push Git Branches to bitbucket

I'm new to Git and having some issues migrating my SVN. I was able to correctly convert to a git repo that looks good on my local machine. When I push it to bitbucket however, I only see the master and none of my branches (which I can see on my local git. )

I see something like.

On my local machine:

$git branch -vva
* master

Bitbucket only shows this master and no branches.

These branches can basically become tags at some point ( mostly just old revisions of the code that are no longer in use.) But I would like them to still exist in the git version.

How can I push what I have locally to bitbucket easily ?

Answer Source

There are two possible reasons that you are not seeing the branches on Bitbucket.

  1. Your question is a duplicate of Firedrill: Recreate central git repository from developers clones, as @ThorbjørnRavnAndersen points out.
  2. You have remote tracking branches in your repository that you are trying to push.

If it's the later, you should know that Git only pushes your local branches to the remote and not your remote tracking branches.

Your local branches are the ones that git prints when you run

git branch      # show only local branches

Your remote tracking branches are the ones that git prints when you run

git branch -r   # show only remote tracking branches

But what you were running was showing you both the local and remote tracking branches

git branch -a   # show both local and remote tracking branches

To make a remote tracking branch a local branch you can run

git branch <local-branch-name> <remote-branch-name>

Or in your specific example

git branch branch1 remotes/branch1

However, I have a feeling that there's more to your repository than you mentioned because the remotes/branch1 is not really the correct convention for branch names...

Can you please provide us with the output of the git branch and git branch -r commands (appropriately redacted for a public forum), and let us know which branches you expect Git to push to Bitbucket?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download