{"id":293,"date":"2022-02-19T11:46:06","date_gmt":"2022-02-19T11:46:06","guid":{"rendered":"https:\/\/santosh-shah.com\/blog\/?p=293"},"modified":"2022-02-20T13:18:42","modified_gmt":"2022-02-20T13:18:42","slug":"track-all-remote-branches-git","status":"publish","type":"post","link":"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/","title":{"rendered":"Track all remote branches GIT"},"content":{"rendered":"\n<p>Here we will show you how to track all remote branches in GIT and get them all at once in your local.<\/p>\n\n\n\n<p>Below is the demo of a git where there are several branches and each branches there are some code. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;github.com\/Santoshah\/firebase-auth<\/code><\/pre>\n\n\n\n<p>To get this clone we simply run the command. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/Santoshah\/firebase-auth<\/code><\/pre>\n\n\n\n<p>Above command is going to give checkout default branch which in this case is a `master`. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>santoshshah@192 firebase-auth % git branch\n* master<\/code><\/pre>\n\n\n\n<p>Even if you run above command this will only show master branch from the git clone. So, in order to trace all remove branch you would need to run below command:-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git branch -r<\/code><\/pre>\n\n\n\n<p>This will get all branches available in that branch.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>santoshshah@192 firebase-auth % git branch -r\n  origin\/HEAD -> origin\/master\n  origin\/lesson-10\n  origin\/lesson-11\n  origin\/lesson-12\n  origin\/lesson-13\n  origin\/lesson-14\n  origin\/lesson-15\n  origin\/lesson-17\n  origin\/lesson-18\n  origin\/lesson-19\n  origin\/lesson-20\n  origin\/lesson-22\n  origin\/lesson-23\n  origin\/lesson-3\n  origin\/lesson-4\n  origin\/lesson-5\n  origin\/lesson-6\n  origin\/lesson-7\n  origin\/lesson-8\n  origin\/lesson-9\n  origin\/master<\/code><\/pre>\n\n\n\n<p>So now you know what other branches are available in that git but still you don&#8217;t have those branch in your local. In ordre to get them in your local you need to run below wired bash script command.<\/p>\n\n\n\n<p>You can track them manually as well by entering below command and replace `&lt;branch>` with the branch name available in remote branches.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git branch --track &lt;branch><\/code><\/pre>\n\n\n\n<p>However you wish to get all the branches at once run the below bash script command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for i in $(git branch -r | grep -vE \"HEAD|master\"); do git branch --track ${i#*\/} $i; done<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout master\ngit pull<\/code><\/pre>\n\n\n\n<p>Update information about the remote branches on your local system:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git fetch --all<\/code><\/pre>\n\n\n\n<p>Update information about the remote branches on your local computer and update local branches:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git pull --all<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here we will show you how to track all remote branches in GIT and get them all at once in your local. Below is the demo of a git where there are several branches and each branches there are some code. To get this clone we simply run the command. Above command is going to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,1],"tags":[12,13,11],"class_list":["post-293","post","type-post","status-publish","format-standard","hentry","category-tips-and-ticks","category-uncategorized","tag-branch","tag-fetch-all","tag-git"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Track all remote branches GIT - Santosh Kumar Shah<\/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:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Track all remote branches GIT - Santosh Kumar Shah\" \/>\n<meta property=\"og:description\" content=\"Here we will show you how to track all remote branches in GIT and get them all at once in your local. Below is the demo of a git where there are several branches and each branches there are some code. To get this clone we simply run the command. Above command is going to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/\" \/>\n<meta property=\"og:site_name\" content=\"Santosh Kumar Shah\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-19T11:46:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-20T13:18:42+00:00\" \/>\n<meta name=\"author\" content=\"Santosh Kumar Shah\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Santosh Kumar Shah\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/\",\"url\":\"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/\",\"name\":\"Track all remote branches GIT - Santosh Kumar Shah\",\"isPartOf\":{\"@id\":\"https:\/\/santosh-shah.com\/blog\/#website\"},\"datePublished\":\"2022-02-19T11:46:06+00:00\",\"dateModified\":\"2022-02-20T13:18:42+00:00\",\"author\":{\"@id\":\"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f\"},\"breadcrumb\":{\"@id\":\"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/santosh-shah.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Track all remote branches GIT\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/#website\",\"url\":\"https:\/\/santosh-shah.com\/blog\/\",\"name\":\"Santosh Kumar Shah\",\"description\":\"JavaScript Developer\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/santosh-shah.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f\",\"name\":\"Santosh Kumar Shah\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g\",\"caption\":\"Santosh Kumar Shah\"},\"description\":\"I am JavaScript developer.\",\"sameAs\":[\"https:\/\/santosh-shah.com\/blog\"],\"url\":\"https:\/\/santosh-shah.com\/blog\/author\/sks7yu\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Track all remote branches GIT - Santosh Kumar Shah","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:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/","og_locale":"en_US","og_type":"article","og_title":"Track all remote branches GIT - Santosh Kumar Shah","og_description":"Here we will show you how to track all remote branches in GIT and get them all at once in your local. Below is the demo of a git where there are several branches and each branches there are some code. To get this clone we simply run the command. Above command is going to [&hellip;]","og_url":"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/","og_site_name":"Santosh Kumar Shah","article_published_time":"2022-02-19T11:46:06+00:00","article_modified_time":"2022-02-20T13:18:42+00:00","author":"Santosh Kumar Shah","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Santosh Kumar Shah","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/","url":"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/","name":"Track all remote branches GIT - Santosh Kumar Shah","isPartOf":{"@id":"https:\/\/santosh-shah.com\/blog\/#website"},"datePublished":"2022-02-19T11:46:06+00:00","dateModified":"2022-02-20T13:18:42+00:00","author":{"@id":"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f"},"breadcrumb":{"@id":"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/santosh-shah.com\/blog\/track-all-remote-branches-git\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/santosh-shah.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Track all remote branches GIT"}]},{"@type":"WebSite","@id":"https:\/\/santosh-shah.com\/blog\/#website","url":"https:\/\/santosh-shah.com\/blog\/","name":"Santosh Kumar Shah","description":"JavaScript Developer","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/santosh-shah.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f","name":"Santosh Kumar Shah","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g","caption":"Santosh Kumar Shah"},"description":"I am JavaScript developer.","sameAs":["https:\/\/santosh-shah.com\/blog"],"url":"https:\/\/santosh-shah.com\/blog\/author\/sks7yu\/"}]}},"_links":{"self":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/posts\/293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/comments?post=293"}],"version-history":[{"count":1,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/posts\/293\/revisions"}],"predecessor-version":[{"id":294,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/posts\/293\/revisions\/294"}],"wp:attachment":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/media?parent=293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/categories?post=293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/tags?post=293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}