Woody Hayday : Blog
Books You Should Read
spacer

1and1 Web Hosting & Git – Installing it for singular dev

January 16, 2012

I have a new project in the works and I thought it about time to get a verioning setup working beyond locally, I don’t want to use a PaaS (like Cloud control) though for this one as its Top Secret (for now.) Yeah Yeah I know, shared web hosting, 1and1 – not so secret eh? Well behind a .htaccess passworded directory is better than sitting on AWS via a PaaS, it is, believe me.

The benefit of using GIT in the way below is that it maintains version history AS WELL as offering a managed host, i.e. it deals with uploading as well as versioning (in 1 git bash push.)

So here’s the scenario – there’s one of you, or maybe a few core founders/dev’s and you want to use GIT to version control your developments of a new web app or site. You already have a shared hosting account with 1and1 which works fine up to 20k hits a day or so, is there really need to have the thing scalable on demand from day one? No? Great, read on. If you REQUIRE scalability off the bat (I bet you don’t, really) then go find a PaaS/jump on AWS, for now here’s how to get GIT versioning (with automatic publication) working on your 1and1 shared hosting.

Firstly go read this, its a great guide that pretty much* got me there (95% of the credit to Abhijit), there’s just a few changes to get it to work on 1and1.

How I did it: GIT on 1and1

Load up your FTP, get to the root of your hosting and make your main site dir, in this case we will call it AppDev1:
/AppDev1
Next make two directories underneath it: “repo” and “live”, I shall explain these after you have made them:
/AppDev1/live
/AppDev1/repo

What these two are going to do is give you a live “root” for your web app/site as well as a GIT repository (which stores all the changes.) By separating them you keep everything simple. [live = web root folder, repo (or whatever you call it) = git bare repository.]

Next locally (on your machine) create a folder which you want to develop in:
C:/EpicNewApp

…And load up GIT BASH (assume you have) and enter the following:
cd "C:/EpicNewApp";
git init;

Next go ahead and load your SSH client (putty) and log into your 1and1 Account (there is guidance on 1and1 under SSH accounts, if you need it.) Once logged in enter the following:

cd "/AppDev1/repo"
git init --bare
cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE="../live" git checkout -f
chmod +x hooks/post-receive

*note: This differs from the aforementioned guide in the address entered under GIT_WORK_TREE, this is the only way I could get this setup to work on 1and1.

You can also simply stick these lines into a file called post-receive and upload the file to the “hooks” folder of your new bare repository (repo), if you are so inclined.

That’s it, your done with the SSH, now you can bind a remote location in GIT BASH (replace the obvious:)
$ git remote add web "ssh://u99999999@yourMain1and1Domain.com/~/AppDev1/repo/"
…And go ahead and push to 1and1 (you will need your SSH password to do so.)
$ git push web +master:refs/heads/master
All being well this should have pushed a version to your /AppDev1/repo folder and also updated the live files as per your changes!

Happy Ghetto Versioning!

Note: As per comments, removed .git reference from link, thanks Ano.

This entry was posted in Code, Projects, Snippets, Web Development, Web Technology and tagged 1and1, ghetto first version, git, ssh. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

18 Comments

  1. Ano
    Posted January 22, 2012 at 8:25 pm
    spacer

    for some reason it doesnt work , it keeps on saying

    blah/nlah.git does not appear to be a git repository
    the remote end hung up unexpectedly

  2. Woody
    Posted January 22, 2012 at 8:40 pm
    spacer

    Hmmm I did get that too, had to keep at it though, are you using the right endpoint? Did you copy it from above?

  3. Ano
    Posted January 22, 2012 at 9:38 pm
    spacer

    yes i am using the right end point

    btw , i have been going through soo many websites , and guess what i even called 1and1 and almost got into a fight with one of there customer support cause he couldnt even understand what i was saying which got me mad

    i think the problem has to do with the public and private keys which are necessarily to do the connection

    the link you provided in your post , assumes that you have your public key saved ~/.ssh/somepublickey

  4. Ano
    Posted January 22, 2012 at 9:42 pm
    spacer

    i am afraid that i have to always upload my code and then do the commit on the server. that would suck really bad

  5. Woody
    Posted January 23, 2012 at 9:09 am
    spacer

    Hmm. I don’t think it’s a private key issue, perhaps our shared hosting resides on different servers or similar, I bet your problem is to do with this dude:

    $ git remote add web “ssh://u99999999@yourMain1and1Domain.com/~/AppDev1/repo/.git”

    I had to change it from the linked article in this to get mine to work, look at the ending bit from /AppDev1 (a folder in the root of your hosting) – where does the git repository actually exist in hard files?

  6. Woody
    Posted January 23, 2012 at 9:09 am
    spacer

    Plus, that’s just how we all used to do it! ha.

  7. Ano
    Posted January 23, 2012 at 3:15 pm
    spacer

    hmmm

    isnt the actual repository exists in the place where you initialize your repository?

    so if i am in the root and i do
    $ git init

    my repository will be @ “ssh://u99999999@yourMain1and1Domain.com/.git

    i also noticed that if i am in a folder called myApp.git then
    git init , doesnt create “.git” folder inside myApp.git. it actually makes myApp.git my repository

    so i am a bit confused about this
    i am going to play a bit with the link but i’ll let you know how it goes since you suspect that the issue has to do with the link

    thanks dude

  8. Woody
    Posted January 23, 2012 at 5:26 pm
    spacer

    It has to be a bare repository, that’s part of it – so it needs to be a folder like “repo.git” (or at least have the git repo in it. Also it seemed to need the ~/ in it before the root for me (I didn’t bother checking why but it needed it.)

    Yeah sounds to me like its the link.

    No worries, Good luck spacer

  9. Ano
    Posted January 25, 2012 at 3:11 am
    spacer

    this is crazy ,

    when i did the following
    —————————————–
    [MY COMPUTER] (master)
    $ git remote add web “ssh://[MY ID]@[MY WEBSITE]/~/AppDev1/repo”

    [MY COMPUTER] (master)
    $ git clone web +master:refs/heads/master
    fatal: repository ‘web’ does not exist <<<<<< this is the error i get

    then i did the following of course after removing the old web
    —————————————————————————————–
    $ git remote add web "ssh://[MY ID]@[MY WEBSITE]/~/AppDev1/repo/.git"

    [MY COMPUTER] (master)
    $ git push web +master:refs/heads/master
    [MY ID]@[MY WEBSITE]'s password: [SOME PASSWORD]
    fatal: '~/AppDev1/repo/.git' does not appear to be a git repository
    fatal: The remote end hung up unexpectedly

    this is really wierd :S

  10. Ano
    Posted January 25, 2012 at 3:17 am
    spacer

    ok i removed the old web again and added the following

    $ git remote add web “ssh://[MY ID]@[MY WEBSITE]/~/AppDev1/repo” <<[this is the first one i tried in my older post]

    then as you may have noticed in my older post , i did
    $ git clone web +master:refs/heads/master

    so now i did push instead
    $ git push web +master:refs/heads/master

    here is the error i receive
    error: src refspec master does not match any.
    error: failed to push some refs to 'ssh://[MY ID]@[MY WEBSITE]/~/AppDev1/repo'

    which is a different error message

  11. Ano
    Posted January 25, 2012 at 3:38 am
    spacer

    done its perfectly working spacer

    so here is a summary of what has happened

    i think i just missed the ‘~’ in my link to my website , and that’s about it

    the last error i got was solved by just adding a file to be committed , it is just complaining about having nothing to push to the server lol

    now there is a lil error from your side , you should remove the .git from the link you have in your description , you dont need that

    i hope this will make this post complete hehe

    thanks alot for all the help man

  12. Woody
    Posted January 25, 2012 at 9:07 am
    spacer

    Ano, No worries! Great to hear you got it working…cool when it does eh? I will adjust post now. Happy Developing spacer

  13. Ano
    Posted January 25, 2012 at 4:48 pm
    spacer

    lmao yah it is really cool when it does
    lol happy developing to you too , this sounds like a xmas greeting spacer
    cheers

  14. Woody
    Posted January 25, 2012 at 6:15 pm
    spacer

    lol yeah it’s my new one. ha.

  15. Ano
    Posted February 6, 2012 at 3:17 pm
    spacer

    Hey Woody
    its me Again lol

    umm do you have any links on how to integrate trac as well with my shared 1and 1 hosting

    let me know if you have any spacer

  16. Woody
    Posted February 6, 2012 at 3:33 pm
    spacer

    Hey Ano,

    No, never used it – although if you find a good link then please do share spacer

  17. Ano
    Posted February 6, 2012 at 11:00 pm
    spacer

    Alrighty, i’ll let u know about it as soon as i do

    i saw few but they are hard to do and lengthy ,

    i might have to go through the links which needs alot of work to be done , because i couldnt find anything simpler

    oh well

    i’ll let u know spacer

    Thanks Woody

  18. Woody
    Posted February 7, 2012 at 9:01 am
    spacer

    Might be worth just getting a virtual server/another host if its tons of work, sure its doable though.

    Cheers Ano

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

Got a Project?
spacer
Categories
Life:
  • Games
  • Ideas
  • Looking Back
  • Looking Forward
  • Music
  • Open Letters
  • Photography
  • WoodyLabs
  • Writing
Business:
  • Affiliate Marketing
  • Business Intelligence
  • Projects
  • Search Engine Optimisation
  • Social Media
  • Software
Code:
  • ASP.Net
  • Browser Compatibility
  • C#
  • CSS
  • Facebook Graph API
  • Javascript
  • PHP
  • Snippets
  • Transactional SQL
  • Web Development
  • Wordpress
Technology:
  • SQL Server
  • SSRS
  • Visualisation
  • Web Technology
  • Wiki Media
Travel
A Quote..
"The purpose of life seems to be to acquaint a man with himself"
Emerson
Blogroll
  • Cara Nahaul
  • Mizanur Rahman
  • My Bookmarks
  • Niall Halsall
  • Rioja Hill
  • William Fish
  • Woody Hayday Flickr
  • Archives
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • September 2010
  • August 2010
  • July 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • July 2009
  • May 2009
  • April 2009
  • January 2009
  • December 2008
  • September 2008
  • August 2008
  • Random Projects
  • dubFiend
  • EPN RSS Translator
  • grabTabs for Chrome
  • HD Visualisations
  • Reddit Wallpaper Grabber
  • yes yes fancy dress
  • Back to top ↑
    gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.