• Community
  • Questions
  • Created a local working copy... guide to creating a bare clone on my webserver?

Created a local working copy... guide to creating a bare clone on my webserver?

I'm a total noob to git, and hate (HATE) working in the Terminal (which is why I'm using SourceTree!).

Here's the issue. I've created my local working copy. Everything's humming along nicely. Now what I want to do is create a bare clone on my webserver, and allow SourceTree to push changes to it.

I'm hosting on MediaTemple. They're set up for git, and I've created my subdomain as they recommend (git.mydomain.com).

The plan is to put the clone in git.mydomain.com, and then push changes which will appear on the live site, mydomain.com

I'm hoping to do all this from within SourceTree but am struggling to determing how to actually achieve that. Is this possible? Is there any kind of guide that can walk me through the steps?

1 answer

1 accepted

Hey Benjamin,

Unfortunately you will have to hop on the server via the terminal in order to initialise the remote repository so you can push to it. By whatever option MediaTemplate give you, presumably SSH access via your terminal so you can log in, go to the remote location pertaining to git.mydomain.com and initalise a bare repository by doing "git init --bare".

In SourceTree you'll then want to add a new remote and specify your MediaTemplate server's URL as the remote. From here you can then push to it because you're probably using the same SSH keys as before from when logging in.

Hope that helps, if not, feel free to ask away!

Thanks Kieran! That's not sooooooobad. So, do I simply initialize a repo on the server, and then push everything to it, or do I have to clone first?

And one completely random question about terminal/repo addres: so I assume you meant I needed to enter the username/url combination (mydomain.com@s#####.gridserver.com). However, my repo is in a subdomain: git.mydomain.com. How do I specify that in SourceTree, since the MediaTemple server address is mydomain.com@s#####.gridserver.com? Not sure if that's making sense (or how familiar you are with MediaTemple).

Thanks for your help!

I'm assuming it needs something like this?


However, everytime I add a server URL, it vanishes...

SoI seem to be getting somewhere:


But I'm getting an error when I try to push:

fatal: '/repo.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

But I know that's the location of the repo I set up server side using git init --bare

Wow!!! I think it worked? Part of the problem is that I'm using CloudFlare on this domain, so you have to use their "direct" subdomain... along with using the absolute path, not just a URL.

For other people's reference (I'm on MediaTemple GS fwiw):


Sorry, last question:

So, my assumption is that if I want to use Git to manage my actual website, I need to create the base repo IN the appropriate folder?

For example, on MediaTemple, the folder /html/ is where you place the index, etc... on other servers the folder is called "public_html."

I place my repo there? Is there anything else I need to do to make sure pushes are reflected in the files on my server?

Hi Ben,

Sorry, I had seen all of these yesterday but was unable to reply. From your last comment it sounds like you're wanting to push changes to the server and the server should be hosting the website. If the bare repository is the one you want to host the website from, i.e. in public_html, then you can't do that. A bare repository doesn't work like a regular working copy, it doesn't have the files as you see in your repository, it has a completely different structure because it keeps an index, not a working copy.

So, if you want to host your code on your MediaTemple server, just use a bare repository as previously discussed, but, if you're looking to host a website in a way where pushing your changes to the server should show the changes, then having a bare repository in your public_html folder just won't work. What you're going to need is a post-commit hook which would run a deployment script to connect to your MT server and either SSH in and copy files over or some other kind of FTP sync script. There's a number of options if you're looking for a deployment solution.

I think I'm headed in the right direction! Thank you SO MUCH for your quick responses. You've been a huge help Kieran!

You're welcome, Benjamin :)

Suggest an answer

Log in or Join to answer
Community showcase
Maarten Cautreels
Posted Thursday in Off-topic

Friday Fun: What's your favourite beer/drink

As a Belgian, beer-lover and home brewer, beer is one of my great passions. I love the fact that with just a few ingredients (usually just water, hop and malt) you can create so many different tastes...

288 views 38 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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot