2

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                                                               
  remotes/branch1
  remotes/branch2

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 ?

  • Possible duplicate of [Firedrill: Recreate central git repository from developers clones](http://stackoverflow.com/questions/12034411/firedrill-recreate-central-git-repository-from-developers-clones) – Thorbjørn Ravn Andersen Oct 13 '16 at 14:30
  • 1
    Did you use `git push --all` to push your local branches? Otherwise you only push the branch you're currently on. – Dekker1 Oct 13 '16 at 14:49
  • If the suggestion from @Dekker doesn't work could you please add the output of `git show-refs` to your question (appropriately redacted for a public forum)? – nonsensickle Oct 13 '16 at 14:55
  • Would you mind changing the title of your question to make it easier to find for those that might be having the same problem? I suggest _"SVN to Git conversion - branches not pushed to Bitbucket"_, or something similar. – nonsensickle Oct 14 '16 at 07:42

1 Answers1

2

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/.

Community
  • 1
  • 1
nonsensickle
  • 4,438
  • 2
  • 34
  • 61
  • You're correct I simulated the outpuit of that function. Ultimately my issues was solved via : https://www.atlassian.com/git/tutorials/migrating-convert/ – Daniel Moss Oct 13 '16 at 16:25
  • I ran the .jar referenced at the bottom of that guide and it restructured my repo into more what I was looking for. I believe your solution was correct however and that I had a heap of remote branches I needed to make local. – Daniel Moss Oct 13 '16 at 16:26
  • So it seems it was option 2. I too learned something today, I didn't know SVN import did that. – nonsensickle Oct 13 '16 at 18:02