It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Workflow to push a local git repository to a hosted one

Ok, this is a toal noob question. I must be missing something pretty obvious.

I'm using Coda to build web apps. I have git repositories in my local source folders that I now manage with SourceTree.

What's the SourceTree workflow to push a local repository to GitHub?

3 answers

1 accepted

8 votes
Answer accepted

In SourceTree you can add a repository using the "Settings" button (top right):

Add a new remote repository and set the URL/path to your Github repository URL. The name can be whatever you want but for the default repository "origin" is a good option :)

The "Push" button in the menu should then allow you to select the repository you just added. Selecting the "Track" option will set up a tracking reference (it'll "link" your local branch to the given branch on the remote).

On the commandlone it looks like this:

git push -u origin master

git will automatically set up a tracking reference to that you can use git push/pull without having to explicitly add the remote and branch you want to push.

Yep there it is, you can do it all via Sourcetree

Thanks Stefan! What puzzled me was that after creating a "hosted" repository using the Create Repository button on the View > Show Hosted Repositories dialog, when I clicked on the "Push" icon it only lets me sleect "Custom" repositories.

The Setings Icon certainly lets me do it. But... It's not the most obvious UI. I need to know that clicking on the little Globe button is how I get to see my "hosted" repository list.

Many thanks for helping a bear of very little brain.

I can see why that might be confusing, it depends on how you got to the Create Repository dialog. If you got to it straight from the top-level hosted repositories view there's no link to any of your own repositories yet, which is why you have to then go into Settings in the repo to set that up. If you'd cloned the repo from GitHub then the remote would already be set up.

In future for new repositories, what you can do is go straight via Settings in the first instance, click Add Remote, and then click the 'World' icon, which brings up the hosted window again, but in the context of this repo. You can then Create Repository from here, and then select it to set up the remote. That way the process is a bit more seamless.

You need to add the github repository as a new remote.

So first create a Github repository and after creating it, it will show you a section with the commands to add it as a remote to your local repository

It will be something like the following from the commandline

git remote add origin git@github.com:user/repository.git

git push origin master

When my mac reboots I'll see how to do that direct in sourcetree :)

Thanks Colin! I saw the command-line instructions for git, but I'm trying to learn the SourceTree GUI. Stefan's answer seems to solve the problem. Thanks for helping!

Can you create a remote repository on Github/Bitbucket directly from SourceTree? I can't find a way to do this. And when I view hosted repos, the option to create new repository is blanked out. BTW I'm using OpenSSH, not putty, is there a reason for this?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Off-topic

Do you still play the same games you played when you were a kid?

Months ago, I was walking in a huge grocery store and I went to the toys aisle and found a jigsaw puzzle that was more than 50% off, and I thought "why not? It will be fun and it can be a beautiful f...

222 views 21 10
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you