{"id":413,"date":"2011-10-10T23:25:24","date_gmt":"2011-10-10T23:25:24","guid":{"rendered":"http:\/\/41j.com\/blog\/?p=413"},"modified":"2011-10-13T09:42:46","modified_gmt":"2011-10-13T09:42:46","slug":"simple-git-example-local-repository","status":"publish","type":"post","link":"https:\/\/41j.com\/blog\/2011\/10\/simple-git-example-local-repository\/","title":{"rendered":"Simple git example (local repository)"},"content":{"rendered":"<p>0. Configure your information:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit config --global user.name &quot;Mr User the user&quot;\r\ngit config --global user.email &quot;mruser@theinternets.com&quot;\r\n<\/pre>\n<p>You can also configure an editor:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit config --global core.editor 'vim'\r\n<\/pre>\n<p>1. Create a repository<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmkdir testproject\r\ncd testproject\r\ngit init\r\n<\/pre>\n<p>2. Commit a file<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ntouch testfile\r\ngit add testfile\r\ngit commit\r\n<\/pre>\n<p>3. Making a release branch<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit branch RB_1.0 master\r\n<\/pre>\n<p>While you&#8217;ve created a release branch, you&#8217;re still currently on the master branch. So if you make a change here:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ntouch testfile2\r\ngit add testfile2\r\ngit commit\r\n<\/pre>\n<p>That file will NOT be in the release branch (RB_1.0).<\/p>\n<p>4. Switching between the master branch and the release branch.<\/p>\n<p>Unlike, SVN which stores different branches in different directories, git uses a command to switch your directory between branches. Slightly confusingly this command is called &#8220;checkout&#8221;.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit checkout RB_1.0\r\n<\/pre>\n<p>If you want, you can make changes to RB_1.0, they wont be refected elsewhere.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ntouch rb1file\r\ngit add rb1file\r\ngit commit\r\n<\/pre>\n<p>5. Releasing<\/p>\n<p>Create a tag:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit tag 1.0 RB_1.0\r\n<\/pre>\n<p>List all tags:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit tag\r\n<\/pre>\n<p>6. Merging<\/p>\n<p>Merge changes from RB_1.0 on to master:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit checkout master\r\ngit rebase RB_1.0\r\n<\/pre>\n<p>7. Delete a branch<\/p>\n<p>It seems to be git practice to delete branches, you can always branch from the tag.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit branch -d RB_1.0\r\n<\/pre>\n<p>8. Creating a tarball<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit archive --format=tar --prefix=testproject1 1.0 &gt; ~\/testproject1.tar\r\n<\/pre>\n<p>9. Changing a file!<\/p>\n<p>This may be slightly different than you were expecting. You can&#8217;t just edit the file and type &#8220;git commit&#8221; rather, you need to add then commit. For example, after editing testfile:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit add testfile\r\ngit commit\r\n<\/pre>\n<p>Git creates commits in two stages like this. The first add &#8220;stages&#8221; the change and commit commits it. You can do multiple adds before the commit. The idea is to let you get everything organised before finally performing the commit.<\/p>\n<h2>Notes on git<\/h2>\n<p>There are no version numbers. A revision is identified by its hash.<\/p>\n<p>master is like trunk in SVN\/CVS.<\/p>\n<p>checkout, doesn&#8217;t really mean checkout. It mean switch between branches.<\/p>\n<p>You can also branch from tags the same way you branch from master.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>0. Configure your information: git config &#8211;global user.name &quot;Mr User the user&quot; git config &#8211;global user.email &quot;mruser@theinternets.com&quot; You can also configure an editor: git config &#8211;global core.editor &#8216;vim&#8217; 1. Create a repository mkdir testproject cd testproject git init 2. Commit a file touch testfile git add testfile git commit 3. Making a release branch git [&hellip;]<\/p>\n","protected":false},"author":1,"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,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[6,8,7],"class_list":["post-413","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-git","tag-revision-control","tag-svn"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1RRoU-6F","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/comments?post=413"}],"version-history":[{"count":3,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/413\/revisions"}],"predecessor-version":[{"id":450,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/413\/revisions\/450"}],"wp:attachment":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/media?parent=413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/categories?post=413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/tags?post=413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}