{"id":5222,"date":"2018-08-22T10:51:53","date_gmt":"2018-08-22T10:51:53","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=5222"},"modified":"2021-02-27T09:07:01","modified_gmt":"2021-02-27T09:07:01","slug":"how-to-update-or-pull-current-branch-before-committing-in-git","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/","title":{"rendered":"How to update or pull current branch before committing in Git?"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5277\" src=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2018\/08\/git-1.png\" alt=\"\" width=\"600\" height=\"350\" srcset=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2018\/08\/git-1.png 600w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2018\/08\/git-1-300x175.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>Best practice says that before you commit in git, you need to either do git pull or git fetch\/merge. However, there is a way to find out wheather your branches is not in sync with remote.<\/p>\n<p><strong>To check the remote repo status you are really simulating a &#8220;fetch&#8221;<\/strong><br \/>\n$ git fetch -v &#8211;dry-run<\/p>\n<p><strong>To bring your remote refs up to date<\/strong><br \/>\n$ git remote -v update<\/p>\n<p><strong>This command will print whether the branch you are tracking is ahead, behind or has diverged with remote. If it says nothing, the local and remote are the same.<\/strong><br \/>\n$ git status -uno<\/p>\n<p><strong>To pull<\/strong><br \/>\n$ git pull origin &lt;&lt;branchname&gt;&gt;<br \/>\nor<br \/>\n$ git fetch origin &lt;&lt;branchname&gt;&gt;<br \/>\n$ git merge remote\/&lt;&lt;branchname&gt;&gt;<br \/>\n$ git commit<\/p>\n<p><strong>Compare the two branches:<\/strong><br \/>\n$ git log HEAD..origin\/master &#8211;oneline<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Best practice says that before you commit in git, you need to either do git pull or git fetch\/merge. However, [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":5277,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[38],"tags":[160,5020,5017,5021,5018,5019,5022],"class_list":["post-5222","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-git","tag-git","tag-git-commit","tag-git-fetch","tag-git-merge","tag-git-pull","tag-git-push","tag-git-remote"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to update or pull current branch before committing in Git? - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to update or pull current branch before committing in Git? - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"Best practice says that before you commit in git, you need to either do git pull or git fetch\/merge. However, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-22T10:51:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-02-27T09:07:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2018\/08\/git-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"scmgalaxy K\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"scmgalaxy K\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/\"},\"author\":{\"name\":\"scmgalaxy K\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"headline\":\"How to update or pull current branch before committing in Git?\",\"datePublished\":\"2018-08-22T10:51:53+00:00\",\"dateModified\":\"2021-02-27T09:07:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/\"},\"wordCount\":147,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/git-1.png\",\"keywords\":[\"git\",\"git commit\",\"git fetch\",\"git merge\",\"git pull\",\"git push\",\"git remote\"],\"articleSection\":[\"Git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/\",\"name\":\"How to update or pull current branch before committing in Git? - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/git-1.png\",\"datePublished\":\"2018-08-22T10:51:53+00:00\",\"dateModified\":\"2021-02-27T09:07:01+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/git-1.png\",\"contentUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/git-1.png\",\"width\":600,\"height\":350},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-update-or-pull-current-branch-before-committing-in-git\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to update or pull current branch before committing in Git?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\",\"name\":\"scmgalaxy K\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"caption\":\"scmgalaxy K\"},\"sameAs\":[\"http:\\\/\\\/www.DevOpsSchool.com\"],\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/scmgalaxy\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to update or pull current branch before committing in Git? - scmGalaxy","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:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/","og_locale":"en_US","og_type":"article","og_title":"How to update or pull current branch before committing in Git? - scmGalaxy","og_description":"Best practice says that before you commit in git, you need to either do git pull or git fetch\/merge. However, [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/","og_site_name":"scmGalaxy","article_published_time":"2018-08-22T10:51:53+00:00","article_modified_time":"2021-02-27T09:07:01+00:00","og_image":[{"width":600,"height":350,"url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2018\/08\/git-1.png","type":"image\/png"}],"author":"scmgalaxy K","twitter_card":"summary_large_image","twitter_misc":{"Written by":"scmgalaxy K","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/"},"author":{"name":"scmgalaxy K","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"headline":"How to update or pull current branch before committing in Git?","datePublished":"2018-08-22T10:51:53+00:00","dateModified":"2021-02-27T09:07:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/"},"wordCount":147,"commentCount":0,"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2018\/08\/git-1.png","keywords":["git","git commit","git fetch","git merge","git pull","git push","git remote"],"articleSection":["Git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/","name":"How to update or pull current branch before committing in Git? - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/#primaryimage"},"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2018\/08\/git-1.png","datePublished":"2018-08-22T10:51:53+00:00","dateModified":"2021-02-27T09:07:01+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/#primaryimage","url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2018\/08\/git-1.png","contentUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2018\/08\/git-1.png","width":600,"height":350},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-update-or-pull-current-branch-before-committing-in-git\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"How to update or pull current branch before committing in Git?"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102","name":"scmgalaxy K","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","caption":"scmgalaxy K"},"sameAs":["http:\/\/www.DevOpsSchool.com"],"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/scmgalaxy\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=5222"}],"version-history":[{"count":2,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5222\/revisions"}],"predecessor-version":[{"id":5278,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5222\/revisions\/5278"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media\/5277"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=5222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=5222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=5222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}