How can I create remote repository (BitBucket) via SourceTree?
Asked by Jakub Pawlik:

Hey. Question is as in the topic - how can I createremote repository (BitBucket) via SourceTree?

I'm complete beginner when it comes to both SourceTree and Git. I've been trying to create remote repository using guide from Unity site (not sure if I can link such things, so I won't) but it seems guide applies to some older version of SourceTree. In guide, after adding your Bitbucket account and skipping step with cloning repository you get step where you can create local or remote repository. Unofrtunately i didn't have it, and now I can't find where to create remote one (I can only find creation of local one, or at least I think it's local).

Not sure if that's connected, but I haven't created SSH key as of yet (not sure what it is for, have rto read about it first).

I know it's probably silly question but before I start looking for some git commend to do just that, I wanted to know if I'm missing something in SourceTree's UI.


Answers:
author: GabrielleJ
body: Just to clarfiy, Are you findng a hard time creating a remote repository in BItbucket? Or a git repository locally using SourceTree? They are complete different.

If you want to start your work, create a git repository locally via SourceTree by just using the "Clone/New" button, in your case it's the NEW button. This just a simple "git init" operation on your desired directory. Put your codes in. Then do a git **commit** then you already have a working git repository.

Now, if you want this git repository to be tracked in a remote git repository (like Bitbucket) you will need to **push** your local git repo to that remote repository. You will need SourceTree to know where are your "remote" repos are. However, you will need to create the git repository in Bitbucket first then do a git remote add origin https://bitbucket.org/your-name/your-repository.


author: Steven Rabulan
body: Seems like you can do this now, in OSX at least.

In your source tree view that shows your repos, right click the repo and click new repository --\> create remote repository

comments: author: mortepcandvr
body: Thx Steven :)

I think you hit the nail on the head - it must be possible only with OSX Sourcetree client app.

I am having same issue on Windows Sourcetree app from that same [Unity Cloud Build integration "HOWTO" Bitbucket+Sourcetree guide](https://unity3d.com/learn/tutorials/topics/cloud-build/creating-your-first-source-control-repository), because the option to create a remote repo on BitBucket from a signed in Sourcetree client app does not exist.

The guide explicitly tells users to cancel out of creating the repo from inside the Bitbucket web GUI, and to do it from Sourcetree client instead - and all the screenshots appear to have OSX window UI, so the Unity tech writers evidently did not test this method on Windows.

(Right clicking repo in Windows Sourcetree repo view does not offer that menu option)

I guess Windows devs will have to just create repos from the Bitbucket web GUI.

\<sigh\>

Luckily, that's pretty easy to do - also Bitbucket explicitly reminds you to generate SSH-2 RSA keys as 2048 bit minimum length, Sourcetree win client does not.

Bitbucket repo create also prompts you to plug in your own .gitignore as the 1st file, which (if you do it right) eliminates a painful step 6 (stage selected \& 1st push/commit) of that Unity guide.


author: Tim Crall
body: Just to quickly address the sSH key part of the question, SSH keys are used to crate a secure way to communicate between the workstation and the remote repo. They are only necessary if you use SSH: protocol in your remote URL rather than HTTP or HTTPS. The advantage to them is that once they are set up, you do not need to enter your username and password every time you push or pull. Like the others who answered, I don't believe there's a way to create a remote Bitbucket repo from within SourceTree. You should log into the Bitbucket web interface and, if you have appropriate permissions, create a repo that way.


author: Johannes Kilian
body: Creating a remote git-repository from your local machine is not possible. As git is a distributed SourceControl System the remote repository can be "anywhere" - not only on Bitbucket server. **You need to have the access permissions on the remote machine to create the remote repository - which is generally not the case.** Therefore you cannot create the remote reepository directly from your machine**.**

It has to be done the other way round:

You have to be (logged in) on the remote machine to create a repository (if you have sufficent permissions) - If you do not have sufficent permissions anybody else has to create the repository and grant you the needed permissions to work with the new (in your eyes: remote) repository. Afterwards you have to connect your local repository to the remote repository via *git add remote ...*or clone the remote repository to be able to work with locally (see above answer from @Gabrielle Bautista \[ACP-JA\])


author: Jakub Pawlik
body: Thanks for clarifying. I've done as advised and created repo directly on BitBucket.I wanted to create it remotely, only because the guide said (with attached screenshot) that it's possible, but maybe it used to be truth in older version and isn't the case anymore.