{"id":1799,"date":"2014-01-24T09:06:14","date_gmt":"2014-01-24T14:06:14","guid":{"rendered":"http:\/\/bitpost.com\/news\/?p=1799"},"modified":"2014-01-27T16:43:49","modified_gmt":"2014-01-27T21:43:49","slug":"using-git-for-personal-distributed-repositories-all-synced-with-one-team-repo","status":"publish","type":"post","link":"https:\/\/bitpost.com\/news\/2014\/using-git-for-personal-distributed-repositories-all-synced-with-one-team-repo\/","title":{"rendered":"Using git for personal distributed repositories all synced with one team repo"},"content":{"rendered":"<p>I&#8217;m a cross-platform developer, with about 17 different development environments.  Most projects have a remote central team repository.  git lets me cast my code out to all my local locations and effortlessly remained synced with the team repo.  In addition, I can work exclusively in my local repos, as long as I need to, without touching the team repo until I&#8217;m ready to push my stuff to it.  I&#8217;ve refined my process down to just the right number of branches to accomplish this.  Here&#8217;s my git bliss:<\/p>\n<p>First, set up a local centralized repo:<\/p>\n<pre><code>ssh me@my-central-repo-server\r\ngit clone ssh:\/\/me@the-team-repo\/big-project\r\ncd big-project\r\ngit branch daily_grind # create working branch but do NOT check it out<\/code><\/pre>\n<p>Next, set up a [git merge-to] command (huge THANKS to <a href=\"https:\/\/gist.github.com\/jthigpen\/8327939\">this gist<\/a>):<\/p>\n<pre><code>emacs .git\/config\r\n  [alias]\r\n    merge-to = \"!gitmergeto() { export tmp_branch=`git branch | grep '* ' | tr -d '* '` && git checkout $1 && git merge $tmp_branch && git checkout $tmp_branch; unset tmp_branch; }; gitmergeto\"<\/code><\/pre>\n<p>Now we can set up a clone in many new locations &#8211; repeat this on each dev box:<\/p>\n<pre><code>ssh me@my-laptop\r\ngit clone ssh:\/\/me@my-central-repo-server\/big-project\r\ncd big-project\r\ngit checkout -b daily_grind origin\/daily_grind<\/code><\/pre>\n<p>This location is now a work site.  Work in the daily_grind branch.  Always pull before you get started working, and push when done:<\/p>\n<pre><code>ssh me@my-laptop\r\ngit pull\r\n# work work work!\r\ngit commit -a\r\ngit push<\/code><\/pre>\n<p>When you are ready to share with the team, all your commits from all your dev locations will be in your central repo, in the daily_grind branch.  Just merge your work with the team&#8217;s:<\/p>\n<pre><code>ssh me@my-central-repo-server\r\ngit pull # to get the team's latest\r\ngit merge daily_grind # to merge in your latest\r\n# resolve any conflicts\r\ngit push # to push your changes to the team\r\ngit merge-to daily_grind # to push team changes to your work repo<\/code><\/pre>\n<p>If there were any team changes, you&#8217;ll get them in your local repos the next time you pull.<\/p>\n<p>And away we go.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m a cross-platform developer, with about 17 different development environments. Most projects have a remote central team repository. git lets me cast my code out to all my local locations and effortlessly remained synced with the team repo. In addition, I can work exclusively in my local repos, as long as I need to, without [&hellip;]<\/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","default_image_id":0,"enabled":false},"version":2}},"categories":[45,19],"tags":[],"class_list":["post-1799","post","type-post","status-publish","format-standard","hentry","category-git","category-opensource"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9M11L-t1","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/1799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/comments?post=1799"}],"version-history":[{"count":5,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/1799\/revisions"}],"predecessor-version":[{"id":1807,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/1799\/revisions\/1807"}],"wp:attachment":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/media?parent=1799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/categories?post=1799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/tags?post=1799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}