{"id":1019,"date":"2016-08-08T12:17:56","date_gmt":"2016-08-08T12:17:56","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2016\/08\/08\/how-to-display-your-local-git-branch-in-your-bash-prompt\/"},"modified":"2021-07-24T15:14:41","modified_gmt":"2021-07-24T15:14:41","slug":"how-to-display-your-local-git-branch-in-your-bash-prompt","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html","title":{"rendered":"How to Display your Local Git Branch in your BASH prompt"},"content":{"rendered":"

In order to make your life easier when working with git, this article provides the steps to display the current local git branch within your bash prompt. This not only saves you time, but also prevents the potential for human error by ensuring you are not making changes to the wrong branch.<\/p>\n

Download Script<\/h2>\n

First all we download the git prompt script.<\/p>\n

curl https:\/\/raw.githubusercontent.com\/git\/git\/master\/contrib\/completion\/git-prompt.sh -o ~\/.git-prompt.sh<\/pre>\n

Update .Bashrc<\/h2>\n

We then add the following lines to ~\/.bashrc<\/span>. <\/p>\n

# import script
source ~\/.git-prompt.sh

# customize\/colorize prompt
export PS1=\"\\e[37m\\t\\e[37m-\\e[97m\\u\\e[92m\\e[92m\\w\\[\\033[m\\]\\e[96m\\$(__git_ps1)\\e[97m\\$ \"<\/pre>\n

Example<\/h2>\n

\"git-bash-example1\" <\/picture><\/p>\n","protected":false},"excerpt":{"rendered":"

In order to make your life easier when working with git, this article provides the steps to display the current local git branch within your bash prompt. This not only saves you time, but also prevents the potential for human error by ensuring you are not making changes to the wrong branch. Download Script First … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":1017,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52],"tags":[],"yoast_head":"\nHow to Display your Local Git Branch in your BASH prompt - Fir3net<\/title>\n<meta name=\"description\" content=\"In order to make your life easier when working with git, this article provides the steps to display the current local git branch within your bash prompt.\" \/>\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.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Display your Local Git Branch in your BASH prompt - Fir3net\" \/>\n<meta property=\"og:description\" content=\"In order to make your life easier when working with git, this article provides the steps to display the current local git branch within your bash prompt.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html\" \/>\n<meta property=\"og:site_name\" content=\"Fir3net\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-08T12:17:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-24T15:14:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.fir3net.com\/wp-content\/uploads\/2016\/08\/images_articles_1471051999_command_prompt.png\" \/>\n\t<meta property=\"og:image:width\" content=\"128\" \/>\n\t<meta property=\"og:image:height\" content=\"128\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rick Donato\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rick Donato\" \/>\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.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html\"},\"author\":{\"name\":\"Rick Donato\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037\"},\"headline\":\"How to Display your Local Git Branch in your BASH prompt\",\"datePublished\":\"2016-08-08T12:17:56+00:00\",\"dateModified\":\"2021-07-24T15:14:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html\"},\"wordCount\":85,\"publisher\":{\"@id\":\"https:\/\/www.fir3net.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/2016\/08\/images_articles_1471051999_command_prompt.png\",\"articleSection\":[\"Linux\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html\",\"url\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html\",\"name\":\"How to Display your Local Git Branch in your BASH prompt - Fir3net\",\"isPartOf\":{\"@id\":\"https:\/\/www.fir3net.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/2016\/08\/images_articles_1471051999_command_prompt.png\",\"datePublished\":\"2016-08-08T12:17:56+00:00\",\"dateModified\":\"2021-07-24T15:14:41+00:00\",\"description\":\"In order to make your life easier when working with git, this article provides the steps to display the current local git branch within your bash prompt.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#primaryimage\",\"url\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/2016\/08\/images_articles_1471051999_command_prompt.png\",\"contentUrl\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/2016\/08\/images_articles_1471051999_command_prompt.png\",\"width\":128,\"height\":128},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.fir3net.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Operating Systems\",\"item\":\"https:\/\/www.fir3net.com\/os\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Linux\",\"item\":\"https:\/\/www.fir3net.com\/os\/linux\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How to Display your Local Git Branch in your BASH prompt\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.fir3net.com\/#website\",\"url\":\"https:\/\/www.fir3net.com\/\",\"name\":\"Fir3net\",\"description\":\"Keeping you in the know\",\"publisher\":{\"@id\":\"https:\/\/www.fir3net.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.fir3net.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.fir3net.com\/#organization\",\"name\":\"Fir3net\",\"url\":\"https:\/\/www.fir3net.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png\",\"contentUrl\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png\",\"width\":390,\"height\":88,\"caption\":\"Fir3net\"},\"image\":{\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037\",\"name\":\"Rick Donato\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g\",\"caption\":\"Rick Donato\"},\"description\":\"Rick Donato is a Network Automation Architect\/Evangelist and the founder of Packet Coders.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Display your Local Git Branch in your BASH prompt - Fir3net","description":"In order to make your life easier when working with git, this article provides the steps to display the current local git branch within your bash prompt.","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.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html","og_locale":"en_US","og_type":"article","og_title":"How to Display your Local Git Branch in your BASH prompt - Fir3net","og_description":"In order to make your life easier when working with git, this article provides the steps to display the current local git branch within your bash prompt.","og_url":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html","og_site_name":"Fir3net","article_published_time":"2016-08-08T12:17:56+00:00","article_modified_time":"2021-07-24T15:14:41+00:00","og_image":[{"width":128,"height":128,"url":"https:\/\/www.fir3net.com\/wp-content\/uploads\/2016\/08\/images_articles_1471051999_command_prompt.png","type":"image\/jpeg"}],"author":"Rick Donato","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rick Donato","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#article","isPartOf":{"@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html"},"author":{"name":"Rick Donato","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037"},"headline":"How to Display your Local Git Branch in your BASH prompt","datePublished":"2016-08-08T12:17:56+00:00","dateModified":"2021-07-24T15:14:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html"},"wordCount":85,"publisher":{"@id":"https:\/\/www.fir3net.com\/#organization"},"image":{"@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#primaryimage"},"thumbnailUrl":"https:\/\/www.fir3net.com\/wp-content\/uploads\/2016\/08\/images_articles_1471051999_command_prompt.png","articleSection":["Linux"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html","url":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html","name":"How to Display your Local Git Branch in your BASH prompt - Fir3net","isPartOf":{"@id":"https:\/\/www.fir3net.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#primaryimage"},"image":{"@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#primaryimage"},"thumbnailUrl":"https:\/\/www.fir3net.com\/wp-content\/uploads\/2016\/08\/images_articles_1471051999_command_prompt.png","datePublished":"2016-08-08T12:17:56+00:00","dateModified":"2021-07-24T15:14:41+00:00","description":"In order to make your life easier when working with git, this article provides the steps to display the current local git branch within your bash prompt.","breadcrumb":{"@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#primaryimage","url":"https:\/\/www.fir3net.com\/wp-content\/uploads\/2016\/08\/images_articles_1471051999_command_prompt.png","contentUrl":"https:\/\/www.fir3net.com\/wp-content\/uploads\/2016\/08\/images_articles_1471051999_command_prompt.png","width":128,"height":128},{"@type":"BreadcrumbList","@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fir3net.com\/"},{"@type":"ListItem","position":2,"name":"Operating Systems","item":"https:\/\/www.fir3net.com\/os"},{"@type":"ListItem","position":3,"name":"Linux","item":"https:\/\/www.fir3net.com\/os\/linux"},{"@type":"ListItem","position":4,"name":"How to Display your Local Git Branch in your BASH prompt"}]},{"@type":"WebSite","@id":"https:\/\/www.fir3net.com\/#website","url":"https:\/\/www.fir3net.com\/","name":"Fir3net","description":"Keeping you in the know","publisher":{"@id":"https:\/\/www.fir3net.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.fir3net.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.fir3net.com\/#organization","name":"Fir3net","url":"https:\/\/www.fir3net.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png","contentUrl":"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png","width":390,"height":88,"caption":"Fir3net"},"image":{"@id":"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037","name":"Rick Donato","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g","caption":"Rick Donato"},"description":"Rick Donato is a Network Automation Architect\/Evangelist and the founder of Packet Coders."}]}},"_links":{"self":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts\/1019"}],"collection":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/comments?post=1019"}],"version-history":[{"count":0,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts\/1019\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/media\/1017"}],"wp:attachment":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/media?parent=1019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/categories?post=1019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/tags?post=1019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}