Pulling from remote (GitHub) to server

I have SSH access to my server and am cloning / pulling from a GitHub repository fine via command line, but I was wondering if there was a way for me to do all this via SourceTree (Version ( / OSX 10.9.2).

Cloning to a local repo, then adding my server as another remote would probably be the easiest (and I know how to do that), however I would like to be able to control when and what gets to this server, hence I'd rather use the copy on the server as a local repository pulling from the GitHub repository.

Is there a way to achieve this in SourceTree?


1 answer

1 accepted

Accepted Answer
1 vote

You might be able to acheive what you want by mounting your server's repo locally, but people have had a lot of trouble using SourceTree (or any other Git client) to treat network storage as a local repository (here, for example.

I would recommend using SourceTree to clone from GitHub locally, add your server as a remote, and push changes from your local instance to the server.

You would still have to use SSH access to keep the server's working copy up to date (git merge to pull changes out of the server's repo into working copy, or git checkout to switch branches).

So the jist of your answer is that it's not possible (or very difficult). Like I said, I know how to add another remote to SourceTree but that would basically push anything to both remotes (GitHub & the server) at the same time, correct? Can these 2 (GH and server) co-exist at all as remotes of the same repo?

You can almost certainly push to just one remote at a time or both, whichever you prefer for a given operation. Remember, Git was designed without any concept of a "central" repository. It is trivial to follow that kind of workflow using Git, but you can also have many remotes with the same repository and push/pull the same commits or different commits in any way you like.

I'd have one more question: I managed to setup my server as 2nd remote, however it's not updating the files on the server. One detail I haven't shared: I also would like to use my server location as the output of my local copy so others can test my online app / website. How can that be done with SourceTree?

To my knowledge, you can't make any changes to a remote's working copy in SourceTree, and probably can't in any other client either. You're better off using an IDE that will automatically FTP changes to a server.

If you want to use Git, you'll need to SSH into the server and run a git merge periodically (which will merge the changes you've pushed to that remote into the remote's working copy).

Thanks for your help!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 08, 2018 in Teamwork

If you could delete any meeting from your calendar, which one would it be?

Let’s face it: most of us have too many meetings on our calendars. And few things are a bigger waste of time than recurring meetings that no longer provide any value to attendees (or the busines...

572 views 16 9
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you