{"id":109,"date":"2009-06-11T15:16:35","date_gmt":"2009-06-11T20:16:35","guid":{"rendered":"http:\/\/stoney.sb.org\/wordpress\/?p=109"},"modified":"2016-02-28T12:09:52","modified_gmt":"2016-02-28T17:09:52","slug":"mirroring-git-respositories-to-dreamhost","status":"publish","type":"post","link":"https:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/","title":{"rendered":"Mirroring git respositories to DreamHost"},"content":{"rendered":"<p>Casper Fabricius has a nice shell script for creating new git repositories on DreamHost. Unfortunately, this works only for creating new repositories.<\/p>\n<p><!--more--><\/p>\n<p>I already have a lot of local git repositories, and this seemed like a much better way to back them up off-site than using github or similar. This is useful only for repositories without collaborators, of course.<\/p>\n<p>Here&#8217;s the shell script. I used Bash just because that&#8217;s my normal shell.<\/p>\n<p>All disclaimers disclaimed. This is not bulletproof.<\/p>\n<pre lang=\"Bash\" line=\"1\">\r\n#!\/bin\/bash\r\n#\r\n# Create a mirror of a local git repos on DreamHost.\r\n# Run this in the root directory of an existing git repository.\r\n# Note that this sets the \"origin\" remote.\r\n#\r\n# Derived from http:\/\/casperfabricius.com\/site\/2008\/09\/21\/keeping-git-repositories-on-dreamhost-using-ssh\/\r\n#\r\n\r\n# change this to your ssh login.\r\nDREAMGIT_DOMAIN=user@domain.com\r\n\r\n# ensure that we're at the top of a git repos\r\nif [ ! -d .git ]; then\r\n\techo \"The current directory is not a git repository\"\r\n\texit 1\r\nfi\r\n# get our directory name and split off the project name\r\ndirPath=`pwd`\r\nbaseProjectName=${dirPath##\/*\/}\r\n# replace spaces with underscores in the project name\r\nprojectName=${baseProjectName\/\/ \/_}\r\n# remove any other troublesome characters\r\nprojectName=${projectName\/\/[^-a-zA-Z0-9_.]\/}\r\n# make the remote mirror on DreamHost\r\nssh $DREAMGIT_DOMAIN 'mkdir -p ~\/git\/'$projectName'.git && cd ~\/git\/'$projectName'.git && git --bare init'\r\n# set the remote as the default push and pull target\r\ngit remote add origin --mirror ssh:\/\/$DREAMGIT_DOMAIN\/~\/git\/$projectName.git\r\n# push all to it\r\necho \"Pushing everything to remote...\"\r\nif git push -v origin; then\r\n\techo \"Git mirror at '$DREAMGIT_DOMAIN\/git\/$projectName.git' all set\"\r\nelse\r\n\techo \"git push failed\"\r\n\texit 1\r\nfi\r\n<\/pre>\n<p>I imagine that this will work for any server to which you can ssh.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Casper Fabricius has a nice shell script for creating new git repositories on DreamHost. Unfortunately, this works only for creating new repositories.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[14],"tags":[26,23,21,22,25,24],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Mirroring git respositories to DreamHost - Stoney&#039;s Zone<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mirroring git respositories to DreamHost - Stoney&#039;s Zone\" \/>\n<meta property=\"og:description\" content=\"Casper Fabricius has a nice shell script for creating new git repositories on DreamHost. Unfortunately, this works only for creating new repositories.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/\" \/>\n<meta property=\"og:site_name\" content=\"Stoney&#039;s Zone\" \/>\n<meta property=\"article:published_time\" content=\"2009-06-11T20:16:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-02-28T17:09:52+00:00\" \/>\n<meta name=\"author\" content=\"stoney\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"stoney\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/\",\"url\":\"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/\",\"name\":\"Mirroring git respositories to DreamHost - Stoney's Zone\",\"isPartOf\":{\"@id\":\"https:\/\/stoney.sb.org\/wordpress\/#website\"},\"datePublished\":\"2009-06-11T20:16:35+00:00\",\"dateModified\":\"2016-02-28T17:09:52+00:00\",\"author\":{\"@id\":\"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/d587bd16a4b79558c4f6e01c078fbdb1\"},\"breadcrumb\":{\"@id\":\"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/stoney.sb.org\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mirroring git respositories to DreamHost\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/stoney.sb.org\/wordpress\/#website\",\"url\":\"https:\/\/stoney.sb.org\/wordpress\/\",\"name\":\"Stoney's Zone\",\"description\":\"Thoughts about stuff\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/stoney.sb.org\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/d587bd16a4b79558c4f6e01c078fbdb1\",\"name\":\"stoney\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/47ff741e5568d1283ae1d29cfa4248fa?s=96&d=mm&r=pg\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/47ff741e5568d1283ae1d29cfa4248fa?s=96&d=mm&r=pg\",\"caption\":\"stoney\"},\"sameAs\":[\"http:\/\/\"],\"url\":\"https:\/\/stoney.sb.org\/wordpress\/author\/stoney\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mirroring git respositories to DreamHost - Stoney's Zone","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/","og_locale":"en_US","og_type":"article","og_title":"Mirroring git respositories to DreamHost - Stoney's Zone","og_description":"Casper Fabricius has a nice shell script for creating new git repositories on DreamHost. Unfortunately, this works only for creating new repositories.","og_url":"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/","og_site_name":"Stoney's Zone","article_published_time":"2009-06-11T20:16:35+00:00","article_modified_time":"2016-02-28T17:09:52+00:00","author":"stoney","twitter_card":"summary_large_image","twitter_misc":{"Written by":"stoney","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/","url":"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/","name":"Mirroring git respositories to DreamHost - Stoney's Zone","isPartOf":{"@id":"https:\/\/stoney.sb.org\/wordpress\/#website"},"datePublished":"2009-06-11T20:16:35+00:00","dateModified":"2016-02-28T17:09:52+00:00","author":{"@id":"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/d587bd16a4b79558c4f6e01c078fbdb1"},"breadcrumb":{"@id":"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/stoney.sb.org\/wordpress\/mirroring-git-respositories-to-dreamhost\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/stoney.sb.org\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Mirroring git respositories to DreamHost"}]},{"@type":"WebSite","@id":"https:\/\/stoney.sb.org\/wordpress\/#website","url":"https:\/\/stoney.sb.org\/wordpress\/","name":"Stoney's Zone","description":"Thoughts about stuff","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/stoney.sb.org\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/d587bd16a4b79558c4f6e01c078fbdb1","name":"stoney","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/47ff741e5568d1283ae1d29cfa4248fa?s=96&d=mm&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/47ff741e5568d1283ae1d29cfa4248fa?s=96&d=mm&r=pg","caption":"stoney"},"sameAs":["http:\/\/"],"url":"https:\/\/stoney.sb.org\/wordpress\/author\/stoney\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p76dm1-1L","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/posts\/109"}],"collection":[{"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":5,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"predecessor-version":[{"id":153,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/posts\/109\/revisions\/153"}],"wp:attachment":[{"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}