{"id":82,"date":"2011-04-12T08:48:47","date_gmt":"2011-04-12T08:48:47","guid":{"rendered":"http:\/\/pixert.com\/blog\/?p=82"},"modified":"2021-03-24T01:15:16","modified_gmt":"2021-03-24T01:15:16","slug":"git-lesson-branch","status":"publish","type":"post","link":"https:\/\/pixert.com\/blog\/git-lesson-branch\/","title":{"rendered":"Git lesson : Branch"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/04\/githeader.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"88\" data-permalink=\"https:\/\/pixert.com\/blog\/git-lesson-branch\/githeader\/\" data-orig-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/04\/githeader.png?fit=71%2C26&amp;ssl=1\" data-orig-size=\"71,26\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Git\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/04\/githeader.png?fit=71%2C26&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/04\/githeader.png?fit=71%2C26&amp;ssl=1\" class=\"alignright size-full wp-image-88\" title=\"Git\" src=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/04\/githeader.png?resize=71%2C26\" alt=\"\" width=\"71\" height=\"26\" \/><\/a>What is GIT?<br \/>\n<a title=\"Git\" href=\"http:\/\/git-scm.com\/\" target=\"_blank\" rel=\"noopener\">Git<\/a> is&#8230;<\/p>\n<blockquote><p>Git is a <strong>free &amp; open source, distributed version control system<\/strong> designed to handle everything from small to very large projects with speed and efficiency.<\/p>\n<p><strong>Every Git clone is a full-fledged repository<\/strong> with complete history and full revision tracking capabilities, not dependent on network access or a central server. <strong>Branching and merging are fast<\/strong> and easy to do.<\/p>\n<p>Git is used for version control of files, much like tools such as <a href=\"http:\/\/mercurial.selenic.com\/\">Mercurial<\/a>, <a href=\"http:\/\/subversion.tigris.org\/\">Subversion<\/a>,  <a href=\"http:\/\/www.nongnu.org\/cvs\/\">CVS<\/a>,  <a href=\"http:\/\/www.perforce.com\/\">Perforce<\/a>,  and <a href=\"http:\/\/msdn.microsoft.com\/en-us\/vstudio\/aa718670.aspx\">Visual SourceSafe<\/a>.<\/p><\/blockquote>\n<p>A single git repository can maintain multiple branches of development.<\/p>\n<p>Get a list of all existing branches<br \/>\n&#8211;<\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\">git branch<\/pre>\n<p>Result : <\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\"> * master <\/pre>\n<p>Create a new branch (named test)<br \/>\n&#8211;<\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\">git branch test<\/pre>\n<p>Switch from default &#8220;master&#8221; to the test branch<br \/>\n&#8211; <\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\">git checkout test<\/pre>\n<p>Force to switch branch from &#8220;master&#8221; to the test branch<br \/>\n&#8211; <\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\">git checkout -f test<\/pre>\n<p>Merge test branch with &#8220;master&#8221; because two branches have diverged, different changes made in each<br \/>\n&#8211; <\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\">git merge test<\/pre>\n<p>If there are conflicts with the changes, show markers<br \/>\n&#8211;<\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\">git diff<\/pre>\n<p>Push the &#8220;test&#8221; branch to remote repo<br \/>\n&#8211; <\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\">git push origin test<\/pre>\n<p>Pull the remote &#8220;test&#8221; branch to local repo<br \/>\n&#8211;<\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\">git pull origin test<\/pre>\n<p>Delete remote &#8220;test&#8221; branch<br \/>\n&#8211;<\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\">git push origin :test<\/pre>\n<p>Delete local &#8220;test&#8221; branch<br \/>\n&#8211;<\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\">git branch -d test<\/pre>\n<p>&gt;&gt; Use it when changes in the test branch are already in &#8220;master&#8221; branch<\/p>\n<p>&#8211;<\/p>\n<pre class=\"brush: bash; title: Code Block; notranslate\" title=\"Code Block\">git branch -D test<\/pre>\n<p>&gt;&gt; force delete test branch<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is GIT? Git is&#8230; Git is a free &amp; open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":88,"comment_status":"closed","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":""},"categories":[34,35],"tags":[50,10,36,51,52],"class_list":["post-82","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mac-os","category-windows","tag-git","tag-linux","tag-mac-os-2","tag-version-control","tag-windows-2"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/04\/githeader.png?fit=71%2C26&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1pvi1-1k","jetpack-related-posts":[{"id":125,"url":"https:\/\/pixert.com\/blog\/git-lesson-branch-is-ahead-by-x-commits\/","url_meta":{"origin":82,"position":0},"title":"Git Lesson : branch is ahead by x commits","author":"Pixel Insert \/ Pixert","date":"July 7, 2011","format":false,"excerpt":"\u00a0\u00a0If Git suddenly popup a warning, \"branch is ahead by x commits\". You can do the following Switch to the branch, e.g it's the Master branch [bash]git checkout master[\/bash] Then, use Git Fetch to\u00a0update the local copy of a remote branch [bash]git fetch[\/bash] Git fetch is similar to pull, except\u2026","rel":"","context":"In &quot;Mac OS&quot;","block_context":{"text":"Mac OS","link":"https:\/\/pixert.com\/blog\/category\/mac-os\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/04\/githeader.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":110,"url":"https:\/\/pixert.com\/blog\/how-to-delete-or-remove-a-local-git-repo-repository\/","url_meta":{"origin":82,"position":1},"title":"How to delete or remove a local Git repo (repository)","author":"Pixel Insert \/ Pixert","date":"May 22, 2011","format":false,"excerpt":"If you want to delete everything (.git folder, files and folders), just delete the whole directory Mac OSX Open Terminal and run the following [bash] rm -rf directoryname [\/bash] Windows Right-click the folder and choose Delete. It will goes to Recycle bin Note: this works for Git Clone and Git\u2026","rel":"","context":"In &quot;Mac OS&quot;","block_context":{"text":"Mac OS","link":"https:\/\/pixert.com\/blog\/category\/mac-os\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/04\/githeader.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":398,"url":"https:\/\/pixert.com\/blog\/ctrl-alt-del-mac\/","url_meta":{"origin":82,"position":2},"title":"CTRL + ALT + DEL on Mac","author":"Pixel Insert \/ Pixert","date":"August 16, 2014","format":false,"excerpt":"I just hit CTRL + ALT + DEL whenever I get frozen on Windows PC, but what to do to when it happens on Mac? what is equivalent to CTRL + ALT + DEL on Mac? Hit 'command' + 'option' + 'esc' simultaneously on keyboard, it'll pops up 'Force Quit\u2026","rel":"","context":"In &quot;Mac OS&quot;","block_context":{"text":"Mac OS","link":"https:\/\/pixert.com\/blog\/category\/mac-os\/"},"img":{"alt_text":"Force Quit Application on Mac","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2014\/08\/cmdoptesc.jpg?fit=372%2C316&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":751,"url":"https:\/\/pixert.com\/blog\/creating-easiest-shortcut-in-mac-os\/","url_meta":{"origin":82,"position":3},"title":"Creating Easiest Shortcut in Mac OS","author":"Pixel Insert \/ Pixert","date":"August 3, 2025","format":false,"excerpt":"I'll give you an example of creating an easy shortcut, it is so easy, it might be easiest shortcut in Mac OS. Mac OS have this app name Shortcuts, this has long been one of the most underrated aspects of Mac OS. Actually, I hadn't touched this app until a\u2026","rel":"","context":"In &quot;Mac OS&quot;","block_context":{"text":"Mac OS","link":"https:\/\/pixert.com\/blog\/category\/mac-os\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2025\/08\/Screenshot-2025-07-31-at-18.56.33.jpg?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2025\/08\/Screenshot-2025-07-31-at-18.56.33.jpg?resize=350%2C200 1x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2025\/08\/Screenshot-2025-07-31-at-18.56.33.jpg?resize=525%2C300 1.5x"},"classes":[]},{"id":229,"url":"https:\/\/pixert.com\/blog\/php-conditional-statement-to-identify-ipad-or-ipod-or-iphone\/","url_meta":{"origin":82,"position":4},"title":"PHP Conditional statements to identify iPad or iPod or iPhone","author":"Pixel Insert \/ Pixert","date":"June 1, 2012","format":false,"excerpt":"This tutorial will show you how to detect iPad or iPod or iPhone using PHP Devices which request content from your website (usually) pass a user agent string. This contains information such as its name, OS, browser version, and rendering engine. Apple\u2019s gadgets pass the following user agents, although you\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?fit=649%2C540&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?fit=649%2C540&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?fit=649%2C540&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":698,"url":"https:\/\/pixert.com\/blog\/boost-your-productivity-with-mac-os-keyboard-shortcuts\/","url_meta":{"origin":82,"position":5},"title":"Boost Your Productivity with Mac OS Keyboard Shortcuts","author":"Pixel Insert \/ Pixert","date":"July 3, 2025","format":false,"excerpt":"I recently discovered the joy of using keyboard shortcuts in Mac OS. It really makes things easier especially speeding up Mac OS usage in case of productivity. I sorted them below by how often they are used. I will update this blog post if I find any new favorite shortcuts.\u2026","rel":"","context":"In &quot;Mac OS&quot;","block_context":{"text":"Mac OS","link":"https:\/\/pixert.com\/blog\/category\/mac-os\/"},"img":{"alt_text":"Mac OS Keyboard Shortcut","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2025\/07\/macosshort-e1751513361491.jpg?fit=826%2C836&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2025\/07\/macosshort-e1751513361491.jpg?fit=826%2C836&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2025\/07\/macosshort-e1751513361491.jpg?fit=826%2C836&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2025\/07\/macosshort-e1751513361491.jpg?fit=826%2C836&ssl=1&resize=700%2C400 2x"},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts\/82","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/comments?post=82"}],"version-history":[{"count":0,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts\/82\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/media\/88"}],"wp:attachment":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/media?parent=82"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/categories?post=82"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/tags?post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}