Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I clone a local git repository with all the commit history to bitbucket.org?

Adrián Alvarez August 4, 2018

I'm new to bitbucket and haven't used git so much either.  I have always worked locally with a git desktop GUI, and I've versioned my software development locally.  Now I created a bitbucket account and I want to upload my code with all commit history.  Is there a way to do it, or do I have to start from where I am now?  I don't mind if I need to use Sourcetree or just the command line.

I'm looking forward to hearing from you!

1 answer

1 vote
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 6, 2018

Hi Adrian, welcome to the Community!

The history of a repo is stored in the .git directory. When you clone a repository, this directory is getting copied too, so the history will remain. Metadata, such as pull requests and Bitbucket comments are not stored, you'll need to reproduce those manually, though. 

Hope that helps!

Ana 

Adrián Alvarez August 6, 2018

Thank you very much... looks exactly what I want.  Which are the steps required to clone a repository FROM local TO Bitbucket?  Or if there's already a tutorial, please send me the link, I couldn't find one for windows.

jredmond
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 6, 2018

First, you'll need to create the repository (or repositories) on Bitbucket first. Leave them empty and do the rest from your system.

Next, go to the local repo and add the remote:

git remote add bitbucket https://username@bitbucket.org/owner/repo.git

OR

git remote add bitbucket git@bitbucket.org:owner/repo.git

where "username" is your username; "owner" is the repository's owner (which might be the same as your username); and "repo" is the name of the repository on Bitbucket. You can name the remote "bitbucket", as I've done in this example, or "origin", or any name that you are not already using.

Then push:

git push bitbucket --mirror

That will populate the repository on the "bitbucket" remote with all branches and tags from your local copy. Please see https://git-scm.com/docs/git-push for more options with the push command.

If you're using a GUI client, like SourceTree, then the concepts are the same (create the repo on BB, add the remote, then push to it) but the specific things to click will vary.

Like mcarico42 likes this
Adrián Alvarez August 7, 2018

Great!!!!  I've done it successfully!!  Thank you very much, now I'll be uploading all my local version control projects here!

Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 10, 2018

So glad to hear that, Adrián! If you need anything else, let us know :) 

Have a nice day,

Ana

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events