{
    "version": "https:\/\/jsonfeed.org\/version\/1.1",
    "title": "Blog — George Mishurovsky: posts tagged git",
    "_rss_description": "A blog by George Mishurovsky — a senior software engineer with a medical degree. Drawing from both engineering and scientific thinking, he explores software, architecture, design, psychology, and product thinking.",
    "_rss_language": "en",
    "_itunes_email": "george@mishurovsky.com",
    "_itunes_categories_xml": "",
    "_itunes_image": "https:\/\/mishurovsky.com\/blog\/pictures\/userpic\/userpic-square@2x.jpg?1753619610",
    "_itunes_explicit": "no",
    "home_page_url": "https:\/\/mishurovsky.com\/blog\/?go=tags\/git\/",
    "feed_url": "https:\/\/mishurovsky.com\/blog\/?go=tags%2Fgit%2Fjson%2F",
    "icon": "https:\/\/mishurovsky.com\/blog\/pictures\/userpic\/userpic@2x.jpg?1753619610",
    "authors": [
        {
            "name": "George Mishurovsky",
            "url": "https:\/\/mishurovsky.com\/blog\/",
            "avatar": "https:\/\/mishurovsky.com\/blog\/pictures\/userpic\/userpic@2x.jpg?1753619610"
        }
    ],
    "items": [
        {
            "id": "53",
            "url": "https:\/\/mishurovsky.com\/blog\/?go=all\/how-to-add-version-control-info-to-zsh-prompt\/",
            "title": "How to Add Version Control Info to zsh Prompt",
            "content_html": "<div class=\"e2-text-picture\">\n<img src=\"https:\/\/mishurovsky.com\/blog\/pictures\/vcs-in-zsh@2x.png\" width=\"1287\" height=\"668\" alt=\"\" \/>\n<\/div>\n<p>MacOS default shell, <span class=\"inline-code\">zsh<\/span>, comes with a neat version control system integration. It works not only with <span class=\"inline-code\">git<\/span>, but also with <span class=\"inline-code\">svn<\/span>, <span class=\"inline-code\">mercurial<\/span>, and many others! The capabilities are quite extensive — you can see yourself in <a href=\"https:\/\/zsh.sourceforge.io\/Doc\/Release\/User-Contributions.html#SEC273\">zsh manual<\/a>.<\/p>\n<p>One thing that I found always missing from default terminal views into folders was if the folder is part of some git repo and which branch is currently checked out. Turns out, about 10 lines of <span class=\"inline-code\">.zshrc<\/span> is enough to provide not only that, but also whether the current branch contains changes, staged and unstaged! I am sharing a script for <span class=\"inline-code\">zsh<\/span> and its alternative for <span class=\"inline-code\">bash<\/span>, which does not have a VCS integration and thus relies on native <span class=\"inline-code\">git<\/span> commands. The result is branch name with <span class=\"inline-code\">+<\/span> and <span class=\"inline-code\">*<\/span> markers appended to the end of folder path, whenever the folder belongs to some git repository.<\/p>\n<h2>Zsh<\/h2>\n<div class=\"e2-code-block\" data-language=\"sh\"><div class=\"e2-code-header\"><span class=\"e2-code-language\">Shell<\/span><button class=\"e2-code-copy\" type=\"button\" aria-label=\"Copy code to clipboard\" data-copy-text=\"Copy\" data-copied-text=\"Copied!\" data-failed-text=\"Failed\"><span class=\"e2-svgi\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 16 16\"><mask id=\"cutout\"><rect width=\"100%\" height=\"100%\" fill=\"white\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" stroke-width=\"1.33\" rx=\"1\" fill=\"black\" stroke=\"black\"\/><\/mask><rect x=\"5.25\" y=\"1.75\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\" mask=\"url(#cutout)\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\"\/><\/svg>\r\n<\/span>Copy<\/button><\/div><pre><code class=\"hljs language-sh\"># Always display version control info in the prompt\nautoload -Uz vcs_info\nautoload -Uz add-zsh-hook\nadd-zsh-hook precmd vcs_info\n\nzstyle &#039;:vcs_info:*&#039; check-for-changes true\nzstyle &#039;:vcs_info:git:*&#039; unstagedstr &#039;%F{red}*%f&#039;\nzstyle &#039;:vcs_info:git:*&#039; stagedstr &#039;%F{green}+%f&#039;\nzstyle &#039;:vcs_info:git:*&#039; formats &#039; %F{cyan}[%b%u%c%F{cyan}]%f&#039;\n\nsetopt PROMPT_SUBST\nPROMPT=&#039;%~${vcs_info_msg_0_} %# &#039;<\/code><\/pre><\/div><h2>Bash<\/h2>\n<div class=\"e2-code-block\" data-language=\"sh\"><div class=\"e2-code-header\"><span class=\"e2-code-language\">Shell<\/span><button class=\"e2-code-copy\" type=\"button\" aria-label=\"Copy code to clipboard\" data-copy-text=\"Copy\" data-copied-text=\"Copied!\" data-failed-text=\"Failed\"><span class=\"e2-svgi\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 16 16\"><mask id=\"cutout\"><rect width=\"100%\" height=\"100%\" fill=\"white\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" stroke-width=\"1.33\" rx=\"1\" fill=\"black\" stroke=\"black\"\/><\/mask><rect x=\"5.25\" y=\"1.75\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\" mask=\"url(#cutout)\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\"\/><\/svg>\r\n<\/span>Copy<\/button><\/div><pre><code class=\"hljs language-sh\">COLOR_CYAN=&#039;\\e[36m&#039;\nCOLOR_RED=&#039;\\e[31m&#039;\nCOLOR_GREEN=&#039;\\e[32m&#039;\nCOLOR_RESET=&#039;\\e[0m&#039;\n\n__git_prompt() {\n    local branch\n\n    # If not a Git repository\n    branch=$(git symbolic-ref --short HEAD 2&gt;\/dev\/null) ||\n        branch=$(git rev-parse --short HEAD 2&gt;\/dev\/null) ||\n        return\n\n    GIT_PROMPT=&quot;${COLOR_CYAN}[${branch}&quot;\n\n    # Staged changes\n    if ! git diff --cached --quiet 2&gt;\/dev\/null; then\n        GIT_PROMPT+=&quot;${COLOR_GREEN}+${COLOR_CYAN}&quot;\n    fi\n\n    # Unstaged changes\n    if ! git diff --quiet 2&gt;\/dev\/null; then\n        GIT_PROMPT+=&quot;${COLOR_RED}*${COLOR_CYAN}&quot;\n    fi\n\n    GIT_PROMPT+=&quot;]${COLOR_RESET}&quot;\n}\n\n__update_prompt() {\n    GIT_PROMPT=&quot;&quot;\n    __git_prompt\n    PS1=&#039;\\w &#039;&quot;${GIT_PROMPT}&quot;&#039; \\$ &#039;\n}\n\nPROMPT_COMMAND=&quot;__update_prompt${PROMPT_COMMAND:+;$PROMPT_COMMAND}&quot;<\/code><\/pre><\/div>",
            "date_published": "2026-08-31T11:33:01+02:00",
            "date_modified": "2026-08-31T11:32:43+02:00",
            "tags": [
                "git",
                "mac",
                "shell"
            ],
            "image": "https:\/\/mishurovsky.com\/blog\/pictures\/Screenshot-2026-08-31-at-11.04.20-2.png.jpg",
            "_date_published_rfc2822": "Mon, 31 Aug 2026 11:33:01 +0200",
            "_rss_guid_is_permalink": "false",
            "_rss_guid": "53",
            "_rss_enclosures": [],
            "_e2_data": {
                "is_favourite": false,
                "links_required": [
                    "highlight\/highlight.js",
                    "highlight\/highlight.css"
                ],
                "og_images": [
                    "https:\/\/mishurovsky.com\/blog\/pictures\/Screenshot-2026-08-31-at-11.04.20-2.png.jpg",
                    "https:\/\/mishurovsky.com\/blog\/pictures\/vcs-in-zsh@2x.png"
                ]
            }
        },
        {
            "id": "11",
            "url": "https:\/\/mishurovsky.com\/blog\/?go=all\/how-to-delete-all-local-git-branches\/",
            "title": "How to Delete All Local Git Branches in One Command",
            "content_html": "<p>First, checkout to main (or any other branch you want to clear from upstream branches).<\/p>\n<p>Now, let’s build the command, step by step.<\/p>\n<ol start=\"1\">\n<li>Check which branches were merged to the current branch:<\/li>\n<\/ol>\n<div class=\"e2-code-block\" data-language=\"sh\"><div class=\"e2-code-header\"><span class=\"e2-code-language\">Shell<\/span><button class=\"e2-code-copy\" type=\"button\" aria-label=\"Copy code to clipboard\" data-copy-text=\"Copy\" data-copied-text=\"Copied!\" data-failed-text=\"Failed\"><span class=\"e2-svgi\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 16 16\"><mask id=\"cutout\"><rect width=\"100%\" height=\"100%\" fill=\"white\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" stroke-width=\"1.33\" rx=\"1\" fill=\"black\" stroke=\"black\"\/><\/mask><rect x=\"5.25\" y=\"1.75\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\" mask=\"url(#cutout)\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\"\/><\/svg>\r\n<\/span>Copy<\/button><\/div><pre><code class=\"hljs language-sh\">git branch --merged<\/code><\/pre><\/div><ol start=\"2\">\n<li>Filter out current branch from the output – it is marked by an asterisk (*):<\/li>\n<\/ol>\n<div class=\"e2-code-block\" data-language=\"sh\"><div class=\"e2-code-header\"><span class=\"e2-code-language\">Shell<\/span><button class=\"e2-code-copy\" type=\"button\" aria-label=\"Copy code to clipboard\" data-copy-text=\"Copy\" data-copied-text=\"Copied!\" data-failed-text=\"Failed\"><span class=\"e2-svgi\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 16 16\"><mask id=\"cutout\"><rect width=\"100%\" height=\"100%\" fill=\"white\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" stroke-width=\"1.33\" rx=\"1\" fill=\"black\" stroke=\"black\"\/><\/mask><rect x=\"5.25\" y=\"1.75\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\" mask=\"url(#cutout)\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\"\/><\/svg>\r\n<\/span>Copy<\/button><\/div><pre><code class=\"hljs language-sh\">git branch --merged | grep -v \\*<\/code><\/pre><\/div><ol start=\"3\">\n<li>Turn the columnar output into a space-separated string:<\/li>\n<\/ol>\n<div class=\"e2-code-block\" data-language=\"sh\"><div class=\"e2-code-header\"><span class=\"e2-code-language\">Shell<\/span><button class=\"e2-code-copy\" type=\"button\" aria-label=\"Copy code to clipboard\" data-copy-text=\"Copy\" data-copied-text=\"Copied!\" data-failed-text=\"Failed\"><span class=\"e2-svgi\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 16 16\"><mask id=\"cutout\"><rect width=\"100%\" height=\"100%\" fill=\"white\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" stroke-width=\"1.33\" rx=\"1\" fill=\"black\" stroke=\"black\"\/><\/mask><rect x=\"5.25\" y=\"1.75\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\" mask=\"url(#cutout)\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\"\/><\/svg>\r\n<\/span>Copy<\/button><\/div><pre><code class=\"hljs language-sh\">git branch --merged | grep -v \\* | xargs<\/code><\/pre><\/div><ol start=\"4\">\n<li>Feed these arguments to the deletion command (passed in the second argument of <span class=\"inline-code\">xargs<\/span>):<\/li>\n<\/ol>\n<div class=\"e2-code-block\" data-language=\"sh\"><div class=\"e2-code-header\"><span class=\"e2-code-language\">Shell<\/span><button class=\"e2-code-copy\" type=\"button\" aria-label=\"Copy code to clipboard\" data-copy-text=\"Copy\" data-copied-text=\"Copied!\" data-failed-text=\"Failed\"><span class=\"e2-svgi\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 16 16\"><mask id=\"cutout\"><rect width=\"100%\" height=\"100%\" fill=\"white\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" stroke-width=\"1.33\" rx=\"1\" fill=\"black\" stroke=\"black\"\/><\/mask><rect x=\"5.25\" y=\"1.75\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\" mask=\"url(#cutout)\"\/><rect x=\"1.75\" y=\"5.25\" width=\"9\" height=\"9\" rx=\"1\" stroke-width=\"1.33\" fill=\"none\"\/><\/svg>\r\n<\/span>Copy<\/button><\/div><pre><code class=\"hljs language-sh\">git branch --merged | grep -v \\* | xargs git branch -D<\/code><\/pre><\/div>",
            "date_published": "2025-08-28T13:46:06+02:00",
            "date_modified": "2025-10-03T23:37:09+02:00",
            "tags": [
                "git",
                "guides",
                "shell"
            ],
            "_date_published_rfc2822": "Thu, 28 Aug 2025 13:46:06 +0200",
            "_rss_guid_is_permalink": "false",
            "_rss_guid": "11",
            "_rss_enclosures": [],
            "_e2_data": {
                "is_favourite": true,
                "links_required": [
                    "highlight\/highlight.js",
                    "highlight\/highlight.css"
                ],
                "og_images": []
            }
        }
    ],
    "_e2_version": 4134,
    "_e2_ua_string": "Aegea 11.3 (v4134e)"
}