{"id":150,"date":"2010-10-06T09:32:04","date_gmt":"2010-10-06T06:32:04","guid":{"rendered":"http:\/\/www.rinta-aho.org\/blog\/?p=150"},"modified":"2015-11-03T12:30:35","modified_gmt":"2015-11-03T10:30:35","slug":"on-git","status":"publish","type":"post","link":"http:\/\/www.rinta-aho.org\/blog\/on-git\/","title":{"rendered":"On Git"},"content":{"rendered":"<p>I am starting to like Git. Check out what it is <a href=\"http:\/\/git-scm.com\/\">here<\/a>. <\/p>\n<p>This is more like a note-to-myself kind of post, but also a crash introduction how to replace a shared CVS repository with Git.<\/p>\n<p>Assume you have Git binaries installed and a directory full of files (maybe tracked with CVS, Subversion, some other version control tool, or not at all &#8211; it really doesn&#8217;t matter). Jump into the directory and type:<br \/>\n<code><br \/>\n> git init .<br \/>\n<\/code><\/p>\n<p>Now you have a Git repository. You can do local commits, you can clone the repository with the &#8216;git clone&#8217; -command, and so on. However, I want to have a central point, which is backed up, and which is a &#8220;hub&#8221; for the other repositories. An example is a &#8220;Documents&#8221; -directory, which I just want to:<\/p>\n<p>a) store &#8220;the state&#8221; on a server,<br \/>\nb) sync between different machines,<br \/>\nc) store the history of changes,<br \/>\nd) store the checksum of each file,<br \/>\ne) be able to do simple &#8216;git push&#8217; and &#8216;git pull&#8217; without extra magic<\/p>\n<p>Here is how to set it up (check out the command explanations from man pages if you care):<\/p>\n<p>On the server, create a bare Git repository:<br \/>\n<code><br \/>\n> mkdir ~\/Documents.git<br \/>\n> cd ~\/Documents.git<br \/>\n> git init --bare .<br \/>\n<\/code><\/p>\n<p>On a machine with the existing Documents directory:<br \/>\n<code><br \/>\n> cd ~\/Documents<br \/>\n> git init .<br \/>\n> git add *.txt<br \/>\n> git commit -m \"Added all old .txt -files.\"<br \/>\n> git remote add server ssh:\/\/server\/home\/user\/Documents.git<br \/>\n> git push server master<br \/>\n> git branch --track m2 server\/master<br \/>\n> git checkout m2<br \/>\n> git branch -d master<br \/>\n> git branch -m m2 master<br \/>\n<\/code><\/p>\n<p>On all other machines, simply:<br \/>\n<code><br \/>\n> git clone server ssh:\/\/server\/home\/user\/Documents.git Documents<br \/>\n> cd Documents<br \/>\n> vim foo.txt<br \/>\n> git add foo.txt<br \/>\n> git commit -m \"Edited foo.txt.\"<br \/>\n> git push<br \/>\n<\/code><\/p>\n<p>After these steps, you can just keep doing &#8216;git commit&#8217;, &#8216;git push&#8217; and &#8216;git pull&#8217; on all of the machines, and the &#8220;hub&#8221; at the server is easy to backup.<\/p>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"http:\/\/www.facebook.com\/sharer.php?u=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F150&#038;t=On%20Git&#038;s=100&#038;p&#091;url&#093;=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F150&#038;p&#091;images&#093;&#091;0&#093;=&#038;p&#091;title&#093;=On%20Git\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"https:\/\/twitter.com\/intent\/tweet?url=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F150&#038;text=On%20Git\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-reddit nolightbox\" data-provider=\"reddit\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Reddit\" href=\"https:\/\/www.reddit.com\/submit?url=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F150&#038;title=On%20Git\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"reddit\" title=\"Share on Reddit\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/reddit.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-pinterest nolightbox\" data-provider=\"pinterest\" target=\"_blank\" rel=\"nofollow\" title=\"Pin it with Pinterest\" href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F150&#038;media=&#038;description=On%20Git\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"pinterest\" title=\"Pin it with Pinterest\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/pinterest.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F150&#038;title=On%20Git\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-32 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=On%20Git&#038;body=http%3A%2F%2Fwww.rinta-aho.org%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F150\" style=\"font-size: 0px;width:32px;height:32px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"32\" height=\"32\" style=\"display: inline;width:32px;height:32px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/www.rinta-aho.org\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/addons\/extra-icons\/image\/social\/clearslate\/64x64\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>I am starting to like Git. Check out what it is here. This is more like a note-to-myself kind of post, but also a crash introduction how to replace a shared CVS repository with Git. Assume you have Git binaries installed and a directory full of files (maybe tracked with CVS, Subversion, some other version &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.rinta-aho.org\/blog\/on-git\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;On Git&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-150","post","type-post","status-publish","format-standard","hentry","category-coding"],"_links":{"self":[{"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/posts\/150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":11,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":161,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/posts\/150\/revisions\/161"}],"wp:attachment":[{"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.rinta-aho.org\/blog\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}