Daniel Moss Daniel Moss - 10 months ago 43
Git Question

SVN to Git conversion - branches not pushed 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... The reason I say that is that the remotes keyword is special and used in refs/remotes/ which is the official prefix of all remote tracking branches.

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?

Edit: From @DanielMoss's comment referring to the Atlassian SVN import process:

Branches and tags are not imported into the new Git repository as you might expect. You won’t find any of your SVN branches in the git branch output, nor will you find any of your SVN tags in the git tag output. But, if you run git branch -r, you’ll find all of the branches and tags from your SVN repository. The git svn clone command imports your SVN branches as remote branches and imports your SVN tags as remote branches prefixed with tags/.