{"id":555497,"date":"2023-02-22T19:00:30","date_gmt":"2023-02-22T16:00:30","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/git-fetch-a-master-class\/"},"modified":"2023-02-22T19:00:30","modified_gmt":"2023-02-22T16:00:30","slug":"git-fetch-a-master-class","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/","title":{"rendered":"#Git Fetch: A Master Class"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2bf53cbee5a\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2bf53cbee5a\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/#%E2%80%9CGit_Fetch_A_Master_Class%E2%80%9D\" >&#8220;Git Fetch: A Master Class&#8221;<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/#What_Is_git_fetch_and_What_Does_It_Do\" >What Is git fetch, and What Does It Do?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/#Git_fetch_vs_pull\" >Git fetch vs. pull<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/#Sync_Your_Local_and_Remote_Repositories_With_git_fetch\" >Sync Your Local and Remote Repositories With git fetch<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/#See_All_Fetched_Tags\" >See All Fetched Tags<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/#Doing_a_Dry_Run_First\" >Doing a Dry Run First<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/#How_to_Fetch_a_Single_Branch\" >How to Fetch a Single Branch<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/#Fetch_All_Branches\" >Fetch All Branches<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/#Comparing_Local_and_Remote_Branches\" >Comparing Local and Remote Branches<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/#Synchronizing_a_Local_Branch_with_a_Remote_Branch\" >Synchronizing a Local Branch\u00a0with a Remote Branch<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/buradabiliyorum.com\/en\/git-fetch-a-master-class\/#The_Half-Trained_Puppy\" >The Half-Trained Puppy<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E2%80%9CGit_Fetch_A_Master_Class%E2%80%9D\"><\/span>&#8220;Git Fetch: A Master Class&#8221;<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<div>\n<!-- UNCACHED CONTENT --><\/p>\n<figure style=\"width: 1920px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage wp-image-872362 size-full\" data-pagespeed-no-defer=\"\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/fatmawati-achmad-zaenuri-321627716.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Linux laptop showing a terminal window with a globe pattern in the background and a binary watermark\" width=\"1920\" height=\"1080\" data-crediturl=\"https:\/\/www.shutterstock.com\/image-vector\/linux-interface-screen-notebook-world-map-321627716\" data-credittext=\"fatmawati achmad zaenuri\/Shutterstock\"\/><figcaption class=\"wp-caption-text\"><span class=\"type:primaryImage imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-vector\/linux-interface-screen-notebook-world-map-321627716\">fatmawati achmad zaenuri\/Shutterstock.com<\/a><\/span><\/figcaption><\/figure>\n<p>The git fetch command is like a git pull command that updates your local repository with information and commits from the remote repository, without overwriting your working files.<\/p>\n<p>The Git <code>fetch<\/code> command lets you look before you leap. You can discover what changes have been made to a remote repository, but without overwriting your local files with the remote files.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"What_Is_git_fetch_and_What_Does_It_Do\"><\/span>What Is git fetch, and What Does It Do?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>fetch<\/code> command in Git <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">download<\/a>s commits, files, and other information from a remote repository to your local repository, safely. Use fetch when you want to see what changes other developers have made, without being forced to accept the changes. Your local files remain untouched. Why is that important?<\/p>\n<p>You have to keep your wits about you when you\u2019re working as part of a development team. The remote or central repository will contain changes and new branches that other developers have created and pushed to the remote repository.<\/p>\n<p>It\u2019s entirely possible that someone has updated the remote copy of files that you\u2019ve modified locally on your computer. If you casually perform a <code>git pull<\/code> to update your local repository, you\u2019re likely find to yourself handling merges for changes you might not even want.<\/p>\n<p>Once you\u2019ve downloaded the information, you can examine it and see what the changes are. This lets you make an informed choice about what you want to merge right now, if anything, and what you want to defer until later.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Git_fetch_vs_pull\"><\/span><a rel=\"nofollow noopener\" target=\"_blank\" name=\"autotoc_anchor_1\">Git fetch vs. pull<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The\u00a0<code>git fetch<\/code>\u00a0command behaves like the <code>git pull<\/code> command but <em>without<\/em> the step that overwrites your local files. Your local repository is updated and synchronized, but the changes are not written to your local repository\u2019s working state, so your files remain untouched.<\/p>\n<p>Or, to put it another way, the <code>git pull<\/code> command is like a <code>git fetch<\/code> followed immediately by a <code>git merge<\/code> .<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Sync_Your_Local_and_Remote_Repositories_With_git_fetch\"><\/span><a rel=\"nofollow noopener\" target=\"_blank\" name=\"autotoc_anchor_2\">Sync Your Local and Remote Repositories With git fetch<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To fetch all the updated metadata and commits from a remote repository to your local repository, use the <code>git fetch<\/code> command with the name or URL of the remote repository. By default, the first remote repository is called \u201corigin.\u201d<\/p>\n<pre>git fetch origin<\/pre>\n<p>You can omit the word \u201corigin\u201d if you\u2019re working with a single remote repository.<\/p>\n<pre>git fetch<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872333\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/1.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using the git fetch command on the default remote repository \" width=\"724\" height=\"230\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>That retrieves any updates from the \u201corigin\u201d repository, but it doesn\u2019t merge the changes into the working files. We can see there is a new branch, called \u201cnew-branch\u201d, that has been retrieved for us.<\/p>\n<p>Once you\u2019ve used the <code>fetch<\/code> command, you can see see the full list of branches on the remote, by using <code>-r<\/code> (remote) option with the branch command.<\/p>\n<pre>git branch -r<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872334\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/2.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Looking at the branches that exist on the default remote\" width=\"724\" height=\"150\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This lists all the branches that the remote knows about, which after the <code>fetch<\/code> , are also in your local repository.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"See_All_Fetched_Tags\"><\/span><a rel=\"nofollow noopener\" target=\"_blank\" name=\"autotoc_anchor_3\">See All Fetched Tags<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Similarly, you can use the <code>tag<\/code> option (note, it\u2019s \u201ctag\u201d without an \u201cs\u201d) to see the list of tags.<\/p>\n<pre>git tag<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872335\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/3.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using the git tag command to list the tags in the local repository\" width=\"724\" height=\"95\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p><strong>RELATED:<\/strong> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/devops\/how-to-switch-add-and-remove-git-remotes\/\"><strong><em>How to Switch, Add, and Remove Git Remotes<\/em><\/strong><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Doing_a_Dry_Run_First\"><\/span>Doing a Dry Run First<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Although a <code>git fetch<\/code> doesn\u2019t merge the changes into your working files, it does still update your local repository. If you want to see what change the <code>fetch<\/code> command will perform, without actually making them, use the <code>--dry-run<\/code> option.<\/p>\n<pre>git fetch --dry-run<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872336\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/5.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using the --dry-run option so see the changes the fetch command would retrieve\" width=\"724\" height=\"230\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"How_to_Fetch_a_Single_Branch\"><\/span><a rel=\"nofollow noopener\" target=\"_blank\" name=\"autotoc_anchor_5\">How to Fetch a Single Branch<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Fetching information about a single branch is easy. Add <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/851425\/git-rename-branch\/\">the name of the branch to the command line to tell <code>fetch<\/code> you only need to know about that one branch.<\/p>\n<p>Here, we\u2019re telling <code>fetch<\/code> to retrieve the branch \u201cmary-feature\u201d from the remote repository \u201corigin.\u201d<\/p>\n<pre>git fetch origin mary-feature<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872337\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/7.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using git fetch to retrieve a single remote branch \" width=\"724\" height=\"150\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Now that the details and contents of the remote branch are in your local repository, you can use the <code>git checkout<\/code> command to create a new branch and checkout the remote branch.\u00a0This won\u2019t over-write any existing files if it\u2019s the first time you\u2019ve used this branch.<\/p>\n<pre>git checkout -b mary-feature origin\/mary-feature<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872338\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/8.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Safely checking out a retrieved remote branch to a new local branch \" width=\"724\" height=\"130\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Fetch_All_Branches\"><\/span>Fetch All Branches<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>If you\u2019re <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/devops\/how-to-use-git-with-multiple-remote-repositories\/\">using multiple remotes, you can save time by pulling all changes from all branches back to your local repository by using the <code>--all<\/code> option.<\/p>\n<pre>git fetch --all<\/pre>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Comparing_Local_and_Remote_Branches\"><\/span>Comparing Local and Remote Branches<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To see how the files in a remote branch differ from your local copies, use <code>git fetch<\/code> , then use the <code>git log<\/code> command.<\/p>\n<p>Note that the local and remote branches have two periods \u201c<code>..<\/code>\u201d separating them. The <code>--oneline <\/code> option shows the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/869305\/git-commit\/\">commit identifier and the commit message.<\/p>\n<pre>git fetch<\/pre>\n<pre>git log --oneline mary-feature..origin\/mary-feature<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872339\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/9.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using git to fetch the remote changes and git log to show the changes\" width=\"724\" height=\"280\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The one-line display is useful if a branch contains a great many changes. To see a little more information, omit the <code>--oneline<\/code> option.<\/p>\n<pre>git log mary-feature..origin\/mary-feature<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872340\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/10.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Omitting the --oneline option so thatgit shows more detail for each commit\" width=\"724\" height=\"170\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This shows us the time and date of each commit, together with the commit message and the contact details of the change author.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Synchronizing_a_Local_Branch_with_a_Remote_Branch\"><\/span>Synchronizing a Local Branch\u00a0with a Remote Branch<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If you\u2019ve decided you want to go ahead and merge the changes from the remote branch to your local working files, you can use these commands.<\/p>\n<p>We\u2019ll checkout the branch to make sure we\u2019re working it is our current, working branch..<\/p>\n<pre>git checkout mary-feature<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872341\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/11.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Checking out a branch\" width=\"724\" height=\"150\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The branch is checked out for us, and we\u2019re told that it is behind the remote version. We can use <code>git pull<\/code> to update it, then <code>git status<\/code> to check our status.<\/p>\n<pre>git pull<\/pre>\n<pre>git status<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872342\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/12.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Pulling changes from the rmeote repository to the local one\" width=\"724\" height=\"270\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>If we\u2019ve made some changes to our local files, Git informs us when we checkout the branch that we\u2019ll need to perform a <code>git pull<\/code> to start a merge.<\/p>\n<pre>git checkout mary-feature<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872344\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/13.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Git informing us that the local and remote brnahces have diverged and need to be merged\" width=\"724\" height=\"150\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>A simple <code>git pull<\/code> starts the process of retrieving the files and merging, or we can dive right in and use <code>git merge<\/code> itself.\u00a0We\u2019ll start by making sure we\u2019re working with the correct branch<\/p>\n<pre>git checkout mary-feature<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872345\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/14.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Git informing us that the local and remote brnahces have diverged and need to be merged\" width=\"724\" height=\"150\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We\u2019ll tell <code>git<\/code> to merge our current branch with the branch in the remote repository, there are six different commits that need to be resolved.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872348\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/17.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"A successful merge message\" width=\"724\" height=\"150\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We need to tell Git which remote branch we want to merge.<\/p>\n<pre>git merge origin\/mary-feature<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872346\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/15.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"using git merge to merge the remote chnages into a local branch\" width=\"724\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>An <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/795509\/why-you-need-a-plain-text-editor\/\">editor opens to allow us to provide a commit message. We can accept the suggested message, or add our own. The editor is your default editor unless Git has been configured to use a different editor.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872347\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/16.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Editing the commit message\" width=\"724\" height=\"170\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Save your changes when you are ready to proceed. The merge carries on automatically when the editor is closed.<\/p>\n<p>Our merge was successful because there were no conflicts.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-872348\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/17.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"A successful merge message\" width=\"724\" height=\"150\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Conflicts arise when the same lines of code are changed by two or more developers. If that is the case,\u00a0Git marks up the conflicts in the affected file. You\u2019ll need to review them in turn and choose which change to keep.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"The_Half-Trained_Puppy\"><\/span>The Half-Trained Puppy<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Just like a puppy in training, <code>fetch<\/code> will retrieve what you ask for, but it won\u2019t drop it. If you actually want what the puppy has shown you, you\u2019ll need to <code>pull<\/code>.<\/p>\n<p><strong>RELATED:<\/strong> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/849210\/git-rebase\/\"><strong><em>Git rebase: Everything You Need to Know<\/em><\/strong><\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/872331\/git-fetch\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;Git Fetch: A Master Class&#8221; fatmawati achmad zaenuri\/Shutterstock.com The git fetch command is like a git pull command that updates your local repository with information and commits from the remote repository, without overwriting your working files. The Git fetch command lets you look before you leap. You can discover what changes have been made to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":555498,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2023\/02\/fatmawati-achmad-zaenuri-321627716.png?height=200p&trim=2,2,2,2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-555497","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/555497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=555497"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/555497\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/555498"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=555497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=555497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=555497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}