Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Workflow to push a local git repository to a hosted one

Richard Milewski November 1, 2011

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
Stefan Saasen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 1, 2011

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.

Colin Goudie
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2011

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

Richard Milewski November 1, 2011

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.

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2011

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.

3 votes
Colin Goudie
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2011

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 :)

Richard Milewski November 1, 2011

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!

0 votes
Roger Qiu April 29, 2014

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
TAGS
AUG Leaders

Atlassian Community Events