SourceTree Windows - Push to BitBucket acocunt?
Asked by thomthom:

I feel I'm missing something obious here, but I can't seem to find what I'm looking for.

I've created a local repo and would like to push it to BitBucket. I see I can remotes to a project, but I've not created a repo at BitBucket. I was wondering if SourceTree was able to do this? Or - what is the procedure for this?

Also, is there a way for SourceTree to link up with BitBucket and list all my BitBucket repos automatically?


Answers:
author: stevestreeting
body: Right now SourceTree for Windows doesn't have the ability to call the Bitbucket API to list your repositories and create new repositories, and grab the remote URLs for you. The Mac version **does** have this, and it will be coming to the Windows version soon.

For now, just create a new repository on Bitbucket via the web interface, then click 'I have code I want to import', then just copy the URL (looks like git@bitbucket.org/yourusername/yournewrepo.git). Then click 'Settings' on the toolbar on your repo tab, click Add to create a new remote, click the 'default remote' checkbox and then paste the URL into the URL / Path box. You can then push to Bitbucket.

comments: author: thomthom
body: Thank you. :)


author: Henri
body: It is now a year later :)Any updates to this feature?

comments: author: thomthom
body: BitBucket has been supported for the Windows client for quite a while now.


author: Henri
body: Great, so I can create Bitbucket repos from Sourcetree?   
Any tips on where I find it/how I do it?

Thanks!

----------

EDIT: No worries, found it in File - Clone...


author: zvodd
body: I hope this image explains it:

1. Click "Clone/New" - ensure you are in the "Clone Repository Tab".
2. Click the Globe/World icon - it's inline with the "Source Path / URL" field.
3. In the "Hosted Repositories" diaglog window that appears; Click "Create New Repository...".

![3 Steps to complete](http://i.imgur.com/HyEO7kQ.png)

comments: author: Cam Newton
body: Sorry, I'm new to version control, and programming in general.

I got this far, but I don't think it's what I'm after, it seems like the direction is local when I want the direction to be out i.e. push to the web. On the Mac you just go "Publish to remote" and your project (that you created locally can be pushed). How would I do that in the Windows version? Can you even do that in-app yet?


author: zvodd
body: This question is about creating a BitBucket remote repository from inside the Source Tree application. (Note, it requires you to add your Bitbucket account in the application preferences).  

Cam Newton, what you appear to be asking is, "How to push to a remote repository?"  
In the case of a local git repo that has a corresponding remote repo, which you should have if you followed the image from above. Then you can simple commit your changes with the "Commit" button and then upload your commit to the remote - known as "Pushing" - with the "Push" button.


author: Cam Newton
body: Hi Zak MO,

Thanks for the quick reply. I apologise if my question is unrelated to the thread topic. I'd just like to make sure by stating my situation. Maybe you can make sense of what I'm trying to ask, as I'm obviously very vague about how the whole thing works!

* I have made and started work on a new Unity project.
* I have committed changes locally
* I wish to push them to my BitBucket account online (without having made a remote repo for this particular project)

What I expected to happen was that I (am able to) hit Push and it detects there isn't a linked remote repo. It would then prompt me to point it to one, or create a new one as part of the one action. Is there something similar where I can do this seamlessly within Sourcetree?

Again, my apologies if my query is off-topic, I'm happy to discuss this in another thread if that's more appropriate!


author: zvodd
body: If you've created a local repo and want to set the remote, I personally do it on the command line:

```
git remote add origin https://&lt;USERNAME&gt;@bitbucket.org/&lt;USERNAME&gt;/&lt;REPONAME&gt;.git
```

There is probably an option to 'set remote' you can find in the menus of source tree.

Also if your doing a unity project, please put this file in the top directory of your repository:  
<https://github.com/github/gitignore/blob/master/Unity.gitignore> and call it ".gitignore"

In Unity you also need to Enable Visible Meta files via Edit-\>Project Settings-\>Editor.  
For git to work with your unity project.


author: Cam Newton
body: Sadly I'm not a command line kind of guy (i'm likely to do more damage than I am good), so I was hoping for a GUI option. I guess I'll just use the workaround and make a repo first in the web browser.

Thanks for the tips on setting Unity up with gitignore too, I'd already struggled past that hurdle! haha