{"id":57582,"date":"2018-05-28T11:00:43","date_gmt":"2018-05-28T08:00:43","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=57582"},"modified":"2019-04-23T14:19:50","modified_gmt":"2019-04-23T11:19:50","slug":"git-remote-branch-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/","title":{"rendered":"Git Remote Branch Example"},"content":{"rendered":"<h2>1. Introduction<\/h2>\n<p><a href=\"https:\/\/git-scm.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Git<\/a> is an open source <a href=\"https:\/\/en.wikipedia.org\/wiki\/Distributed_version_control\" target=\"_blank\" rel=\"noopener noreferrer\">distributed version control system<\/a> designed to handle everything from small to large projects with speed and efficiency.&nbsp;<a href=\"http:\/\/themasterworld.com\/git-three-tree-architecture-key-concepts\/\" target=\"_blank\" rel=\"noopener noreferrer\">Three-tree architecture<\/a>&nbsp;is the&nbsp;key concept. Here are the three trees:<\/p>\n<ul>\n<li>Repository tree &#8211; The place to store the committed files. It can be local or remote. The remote repository is used to track the same project but is stored somewhere else.<\/li>\n<li>Working tree &#8211;&nbsp;The tree of actual files that you are currently working on. It normally contains the check out files and any local changes that you have made but not yet committed.<\/li>\n<li>Staging index tree &#8211; It acts as an interface between a repository and a working tree. It prepares the committing files.<\/li>\n<\/ul>\n<p><figure id=\"attachment_57605\" aria-describedby=\"caption-attachment-57605\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-component.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57605\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-component.jpg\" alt=\"\" width=\"800\" height=\"465\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-component.jpg 800w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-component-300x174.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-component-768x446.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-57605\" class=\"wp-caption-text\">Figure 1 GIT Repositories<\/figcaption><\/figure><\/p>\n<p>This diagram shows my open source project &#8211; <a href=\"https:\/\/github.com\/maryzheng01\/Deadlock-demo\" target=\"_blank\" rel=\"noopener noreferrer\">Deadlock-demo<\/a>&#8216;s local and remote repositories.<\/p>\n<p>In this example, I will demonstrate how to manage remote branches via <code>EGit<\/code>.\n<\/p>\n<h2>2. Technologies and Tools Used<\/h2>\n<ul>\n<li>Java 1.8.101 (1.8.x will do fine)<\/li>\n<li>Maven 3.3.9 (3.3.x will do fine)<\/li>\n<li>Eclipse Mars (Any Java IDE would work)<\/li>\n<li>Git 2.16.*<\/li>\n<\/ul>\n<h2>3. Use Cases<\/h2>\n<p><code>Deadlock-Demo<\/code>&nbsp;is my open source project hosted in GitHub at&nbsp;<a href=\"https:\/\/github.com\/maryzheng01\/Deadlock-demo\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/maryzheng01\/Deadlock-demo<\/a>. It has a default <code>master<\/code> branch. In this example, I created two remote branches from the <code>master<\/code>:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/maryzheng01\/Deadlock-demo\/tree\/Branch-Bug101-Alex\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/maryzheng01\/Deadlock-demo\/tree\/Branch-Bug101-Alex<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/maryzheng01\/Deadlock-demo\/tree\/Branch-Bug101-Mary\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/maryzheng01\/Deadlock-demo\/tree\/Branch-Bug101-Mary<\/a><\/li>\n<\/ul>\n<p><a href=\"http:\/\/www.eclipse.org\/egit\/\" target=\"_blank\" rel=\"noopener noreferrer\">EGit<\/a> is&nbsp;the Git integration for the Eclipse IDE. Click <a href=\"https:\/\/eclipsesource.com\/blogs\/tutorials\/egit-tutorial\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a> for more details. I will demonstrate below use cases with <code>EGit<\/code>:<\/p>\n<ol>\n<li>Clone the <code>master<\/code>&nbsp;branch to a local repository.<\/li>\n<li>Modify the working files and then push the changes to the remote <code>master<\/code> branch.<\/li>\n<li>Switch the working files to <code>Branch-Bug101-Mary<\/code>&nbsp;and push the changes to&nbsp;the remote&nbsp;<code>Branch-Bug101-Mary<\/code>.<\/li>\n<li>Repeat step 3 for&nbsp;<code>Branch-Bug101-Alex<\/code>.<\/li>\n<li>Merge the changes from <code>Branch-Bug101-Mary<\/code> to <code>Branch-Bug101-Alex<\/code> and push&nbsp;the changes to the remote <code>Branch-Bug101-Alex<\/code>.<\/li>\n<\/ol>\n<h2>4. Clone from a Remote Repository<\/h2>\n<p>In this step, I will clone the source codes from a&nbsp;<code>master<\/code> branch via <code>EGit<\/code>:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ol>\n<li>Click Window-&gt;Perspective -&gt;Open Perspective -&gt;Other&#8230;-&gt;Git to switch to <code>Git<\/code> perspective.<\/li>\n<li>In <code>Git<\/code>&nbsp;perspective window, click the cloning icon to&nbsp;clone from a remote repository.<\/li>\n<li>Enter the remote repository data as the screenshot below (replace the login with your credentials) and then click <code>Next<\/code> button.\n<p><figure id=\"attachment_57607\" aria-describedby=\"caption-attachment-57607\" style=\"width: 783px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57607\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone.jpg\" alt=\"\" width=\"783\" height=\"632\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone.jpg 783w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-300x242.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-768x620.jpg 768w\" sizes=\"(max-width: 783px) 100vw, 783px\" \/><\/a><figcaption id=\"caption-attachment-57607\" class=\"wp-caption-text\">Figure 2 Git Clone<\/figcaption><\/figure><\/li>\n<li>Check all three remote branches, and then click the&nbsp;<code>Next<\/code> button.\n<p><figure id=\"attachment_57610\" aria-describedby=\"caption-attachment-57610\" style=\"width: 706px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57610\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-2.jpg\" alt=\"\" width=\"706\" height=\"624\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-2.jpg 706w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-2-300x265.jpg 300w\" sizes=\"(max-width: 706px) 100vw, 706px\" \/><\/a><figcaption id=\"caption-attachment-57610\" class=\"wp-caption-text\">Figure 3 Clone &#8211; Branch<\/figcaption><\/figure><\/li>\n<li>Set the local repository location; leave all others as the default value.&nbsp;Click <code>Finish<\/code>.\n<p><figure id=\"attachment_57611\" aria-describedby=\"caption-attachment-57611\" style=\"width: 694px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57611\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-3.jpg\" alt=\"\" width=\"694\" height=\"629\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-3.jpg 694w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-3-300x272.jpg 300w\" sizes=\"(max-width: 694px) 100vw, 694px\" \/><\/a><figcaption id=\"caption-attachment-57611\" class=\"wp-caption-text\">Figure 4 Clone &#8211; Local Repo<\/figcaption><\/figure><\/li>\n<li>You can expand the <code>Remote Tracking<\/code> folder to list the remote repositories.\n<p><figure id=\"attachment_57612\" aria-describedby=\"caption-attachment-57612\" style=\"width: 757px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-4.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57612\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-4.jpg\" alt=\"\" width=\"757\" height=\"411\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-4.jpg 757w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-4-300x163.jpg 300w\" sizes=\"(max-width: 757px) 100vw, 757px\" \/><\/a><figcaption id=\"caption-attachment-57612\" class=\"wp-caption-text\">Figure 5 Cloned<\/figcaption><\/figure><\/li>\n<\/ol>\n<h2>5<a name=\"heading6\"><\/a>. Modify and Commit the Changes<\/h2>\n<p>In this step, I will show you how to modify, commit, and push the changes to the remote repository.<\/p>\n<ol>\n<li>In <code>Git<\/code> Perspective, right-click the <code>Deadlock-Demo<\/code> project and select <code>Import Projects...<\/code>\n<p><figure id=\"attachment_57656\" aria-describedby=\"caption-attachment-57656\" style=\"width: 449px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-5.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57656\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-5.jpg\" alt=\"\" width=\"449\" height=\"451\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-5.jpg 449w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-5-150x150.jpg 150w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-5-300x300.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Clone-5-70x70.jpg 70w\" sizes=\"(max-width: 449px) 100vw, 449px\" \/><\/a><figcaption id=\"caption-attachment-57656\" class=\"wp-caption-text\">Figure 6 Import<\/figcaption><\/figure><\/li>\n<li>Modify the source files and save the changes.<\/li>\n<li>Select <code>Deadlock-Demo<\/code>, right-click to select Team-&gt;Commit&#8230;<\/li>\n<li>Drag and drop the files from <code>Unstaged Changes<\/code> to <code>Staged Changes<\/code>.<br \/>\n<figure id=\"attachment_57657\" aria-describedby=\"caption-attachment-57657\" style=\"width: 686px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57657\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-2.jpg\" alt=\"\" width=\"686\" height=\"360\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-2.jpg 686w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-2-300x157.jpg 300w\" sizes=\"(max-width: 686px) 100vw, 686px\" \/><\/a><figcaption id=\"caption-attachment-57657\" class=\"wp-caption-text\">Figure 7 Modified<\/figcaption><\/figure><\/p>\n<p><figure id=\"attachment_57658\" aria-describedby=\"caption-attachment-57658\" style=\"width: 685px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57658\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-3.jpg\" alt=\"\" width=\"685\" height=\"677\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-3.jpg 685w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-3-300x296.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-3-70x70.jpg 70w\" sizes=\"(max-width: 685px) 100vw, 685px\" \/><\/a><figcaption id=\"caption-attachment-57658\" class=\"wp-caption-text\">Figure 8 Staged<\/figcaption><\/figure><\/li>\n<li>Click the <code>Commit and Push<\/code> button and click <code>OK<\/code> to confirm.\n<p><figure id=\"attachment_57659\" aria-describedby=\"caption-attachment-57659\" style=\"width: 693px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-4.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57659\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-4.jpg\" alt=\"\" width=\"693\" height=\"474\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-4.jpg 693w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-E-Commit-4-300x205.jpg 300w\" sizes=\"(max-width: 693px) 100vw, 693px\" \/><\/a><figcaption id=\"caption-attachment-57659\" class=\"wp-caption-text\">Figure 9 Commit<\/figcaption><\/figure><\/li>\n<li>Verify by checking the GitHub repository.\n<p><figure id=\"attachment_57660\" aria-describedby=\"caption-attachment-57660\" style=\"width: 739px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-hub_verify.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57660\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-hub_verify.jpg\" alt=\"\" width=\"739\" height=\"431\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-hub_verify.jpg 739w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/Git-hub_verify-300x175.jpg 300w\" sizes=\"(max-width: 739px) 100vw, 739px\" \/><\/a><figcaption id=\"caption-attachment-57660\" class=\"wp-caption-text\">Figure 10 Verify from GitHub<\/figcaption><\/figure><\/li>\n<\/ol>\n<h2>6. Switch to a Different Branch<\/h2>\n<p><code>EGit<\/code> provides an easy way to switch to a different branch. In this step, I will show you how to switch to a different branch.[ulp id=&#8217;pzgfvmZhgslwSymm&#8217;]<\/p>\n<p>First, you select the <code>Deadlock-Demo<\/code> project. Then right-click and select Team-&gt;Switch to-&gt;New Branch&#8230;<\/p>\n<p>Select&nbsp;<code>Branch-Bug101-Mary<\/code>and then click <code>Finish<\/code>.<\/p>\n<p><figure id=\"attachment_57673\" aria-describedby=\"caption-attachment-57673\" style=\"width: 695px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-switch_branch-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57673\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-switch_branch-1.jpg\" alt=\"\" width=\"695\" height=\"428\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-switch_branch-1.jpg 695w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-switch_branch-1-300x185.jpg 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><figcaption id=\"caption-attachment-57673\" class=\"wp-caption-text\">Figure 11 Switch to ok<\/figcaption><\/figure><\/p>\n<p>Modify the source codes, save them, and follow <a href=\"#heading6\">step 5<\/a>&nbsp;to commit to the remote branch.<\/p>\n<p>Repeat these steps for <code>Branch-Bug101-Alex<\/code>.<\/p>\n<h2>7. Merge between Branches<\/h2>\n<p>In this step, I will demonstrate how to merge the changes from&nbsp;<code>Branch-Bug101-Mary<\/code>&nbsp;to&nbsp;<code>Branch-Bug101-Alex<\/code>.<\/p>\n<p>First, follow <a href=\"#heading6\">step 5<\/a>&nbsp;to switch to&nbsp;<code>Branch-Bug101-Alex<\/code>. Select it and right-click Team-&gt;Merge&#8230;<\/p>\n<p>Select the source <code>Branch-Bug101-Mary<\/code>, leave others as the default value, and then click <code>Merge<\/code>.<\/p>\n<p>It will pop a new window for merge results.<\/p>\n<p><figure id=\"attachment_57675\" aria-describedby=\"caption-attachment-57675\" style=\"width: 664px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57675\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex.jpg\" alt=\"\" width=\"664\" height=\"723\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex.jpg 664w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex-276x300.jpg 276w\" sizes=\"(max-width: 664px) 100vw, 664px\" \/><\/a><figcaption id=\"caption-attachment-57675\" class=\"wp-caption-text\">Figure 12 Merge 1<\/figcaption><\/figure><\/p>\n<p>It pops out a new window for the merge result.<\/p>\n<p><figure id=\"attachment_57677\" aria-describedby=\"caption-attachment-57677\" style=\"width: 571px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_ok.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57677\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_ok.jpg\" alt=\"\" width=\"571\" height=\"259\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_ok.jpg 571w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_ok-300x136.jpg 300w\" sizes=\"(max-width: 571px) 100vw, 571px\" \/><\/a><figcaption id=\"caption-attachment-57677\" class=\"wp-caption-text\">Figure 13 Merged OK<\/figcaption><\/figure><\/p>\n<p>After you merge, you will see that there is an up arrow with a number 2 right next to the project. It indicates that there are two commits that can be pushed to upstream.<\/p>\n<p><figure id=\"attachment_57676\" aria-describedby=\"caption-attachment-57676\" style=\"width: 478px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57676\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_2.jpg\" alt=\"\" width=\"478\" height=\"482\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_2.jpg 478w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_2-150x150.jpg 150w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_2-298x300.jpg 298w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_2-70x70.jpg 70w\" sizes=\"(max-width: 478px) 100vw, 478px\" \/><\/a><figcaption id=\"caption-attachment-57676\" class=\"wp-caption-text\">Figure 14 Merged<\/figcaption><\/figure><\/p>\n<p>Select&nbsp;<code>Branch-Bug101-Alex<\/code>, right-click Team-&gt;Push to Upstream.<\/p>\n<p><figure id=\"attachment_57678\" aria-describedby=\"caption-attachment-57678\" style=\"width: 699px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_push.jpg\"><img decoding=\"async\" class=\"size-full wp-image-57678\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_push.jpg\" alt=\"\" width=\"699\" height=\"475\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_push.jpg 699w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/git-merge-Mary-toAlex_push-300x204.jpg 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><figcaption id=\"caption-attachment-57678\" class=\"wp-caption-text\">Figure 15 Pushed<\/figcaption><\/figure><\/p>\n<h2>8. Summary<\/h2>\n<p>In this example, I showed how to clone a project from a remote repository, then update them and commit the changes back to the remote repository. I also demonstrated how to switch to a different branch and how to merge the changes between two branches via <code>EGit<\/code>.&nbsp;These steps are part of a&nbsp;<a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Git-Branching-Branching-Workflows\" target=\"_blank\" rel=\"noopener noreferrer\">Git branching workflow<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction Git is an open source distributed version control system designed to handle everything from small to large projects with speed and efficiency.&nbsp;Three-tree architecture&nbsp;is the&nbsp;key concept. Here are the three trees: Repository tree &#8211; The place to store the committed files. It can be local or remote. The remote repository is used to track &hellip;<\/p>\n","protected":false},"author":140,"featured_media":27377,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1353],"tags":[],"class_list":["post-57582","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-git"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Git Remote Branch Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"1. Introduction Git is an open source distributed version control system designed to handle everything from small to large projects with speed and\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git Remote Branch Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"1. Introduction Git is an open source distributed version control system designed to handle everything from small to large projects with speed and\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-28T08:00:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-23T11:19:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mary Zheng\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mary Zheng\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/\"},\"author\":{\"name\":\"Mary Zheng\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae\"},\"headline\":\"Git Remote Branch Example\",\"datePublished\":\"2018-05-28T08:00:43+00:00\",\"dateModified\":\"2019-04-23T11:19:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/\"},\"wordCount\":855,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"articleSection\":[\"Git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/\",\"name\":\"Git Remote Branch Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"datePublished\":\"2018-05-28T08:00:43+00:00\",\"dateModified\":\"2019-04-23T11:19:50+00:00\",\"description\":\"1. Introduction Git is an open source distributed version control system designed to handle everything from small to large projects with speed and\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Software Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Git\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/git\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Git Remote Branch Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae\",\"name\":\"Mary Zheng\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg\",\"caption\":\"Mary Zheng\"},\"description\":\"Mary has graduated from Mechanical Engineering department at ShangHai JiaoTong University. She also holds a Master degree in Computer Science from Webster University. During her studies she has been involved with a large number of projects ranging from programming and software engineering. She works as a senior Software Engineer in the telecommunications sector where she acts as a leader and works with others to design, implement, and monitor the software solution.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/mary-zheng\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Git Remote Branch Example - Java Code Geeks","description":"1. Introduction Git is an open source distributed version control system designed to handle everything from small to large projects with speed and","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":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/","og_locale":"en_US","og_type":"article","og_title":"Git Remote Branch Example - Java Code Geeks","og_description":"1. Introduction Git is an open source distributed version control system designed to handle everything from small to large projects with speed and","og_url":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-05-28T08:00:43+00:00","article_modified_time":"2019-04-23T11:19:50+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","type":"image\/jpeg"}],"author":"Mary Zheng","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Mary Zheng","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/"},"author":{"name":"Mary Zheng","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae"},"headline":"Git Remote Branch Example","datePublished":"2018-05-28T08:00:43+00:00","dateModified":"2019-04-23T11:19:50+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/"},"wordCount":855,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","articleSection":["Git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/","url":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/","name":"Git Remote Branch Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","datePublished":"2018-05-28T08:00:43+00:00","dateModified":"2019-04-23T11:19:50+00:00","description":"1. Introduction Git is an open source distributed version control system designed to handle everything from small to large projects with speed and","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-remote-branch-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Software Development","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/"},{"@type":"ListItem","position":3,"name":"Git","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/git\/"},{"@type":"ListItem","position":4,"name":"Git Remote Branch Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae","name":"Mary Zheng","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg","caption":"Mary Zheng"},"description":"Mary has graduated from Mechanical Engineering department at ShangHai JiaoTong University. She also holds a Master degree in Computer Science from Webster University. During her studies she has been involved with a large number of projects ranging from programming and software engineering. She works as a senior Software Engineer in the telecommunications sector where she acts as a leader and works with others to design, implement, and monitor the software solution.","url":"https:\/\/examples.javacodegeeks.com\/author\/mary-zheng\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/57582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/140"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=57582"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/57582\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/27377"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=57582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=57582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=57582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}