[{"data":1,"prerenderedAt":172},["ShallowReactive",2],{"post:git-show-file-from-branch":3},{"id":4,"title":5,"body":6,"date":160,"description":161,"draft":162,"extension":163,"meta":164,"navigation":165,"path":166,"seo":167,"stem":168,"tags":169,"__hash__":171},"posts\u002Fposts\u002Fgit-show-file-from-branch.md","TIL: Show File from Branch in Git",{"type":7,"value":8,"toc":158},"minimark",[9,22,29,36,87,90,103,154],[10,11,12,13,17,18,21],"p",{},"This is an interesting one I learned while setting up a ",[14,15,16],"code",{},"\u002Fdraft-gitlab-release"," skill. Since I manually bump version numbers in this project, it's important to compare the live version number first, so I don't accidentally double-bump the version number on ",[14,19,20],{},"development",".",[10,23,24,25,28],{},"I normally use ",[14,26,27],{},"git checkout master && cat box.json | grep version"," to quickly check the version number. However, this is a bit unwieldy as it requires switching branches, and often requires stashing my local changes as well.",[10,30,31,32,35],{},"In drafting this skill, GitHub Copilot recommended the ",[14,33,34],{},"git show"," command instead. The syntax is:",[37,38,43],"pre",{"className":39,"code":40,"language":41,"meta":42,"style":42},"language-bash shiki shiki-themes github-light github-dark","git show \u003Cbranch_name>:\u003Cfile_path>\n","bash","",[14,44,45],{"__ignoreMap":42},[46,47,50,54,58,62,65,69,72,75,78,81,84],"span",{"class":48,"line":49},"line",1,[46,51,53],{"class":52},"sScJk","git",[46,55,57],{"class":56},"sZZnC"," show",[46,59,61],{"class":60},"szBVR"," \u003C",[46,63,64],{"class":56},"branch_nam",[46,66,68],{"class":67},"sVt8B","e",[46,70,71],{"class":60},">",[46,73,74],{"class":56},":",[46,76,77],{"class":60},"\u003C",[46,79,80],{"class":56},"file_pat",[46,82,83],{"class":67},"h",[46,85,86],{"class":60},">\n",[10,88,89],{},"This will display the contents of the specified file from the specified branch without checking out the branch at all!",[10,91,92,93,96,97,99,100,74],{},"Using this and ",[14,94,95],{},"jq"," to parse the version numbers, I can quickly compare version numbers between ",[14,98,20],{}," and ",[14,101,102],{},"main",[37,104,106],{"className":39,"code":105,"language":41,"meta":42,"style":42},"developmentVersion=\"$(jq -r '.version' box.json)\"\nmainVersion=\"$(git show main:box.json | jq -r '.version')\"\n",[14,107,108,128],{"__ignoreMap":42},[46,109,110,113,116,119,121,125],{"class":48,"line":49},[46,111,112],{"class":67},"developmentVersion",[46,114,115],{"class":60},"=",[46,117,118],{"class":56},"\"$(",[46,120,95],{"class":52},[46,122,124],{"class":123},"sj4cs"," -r",[46,126,127],{"class":56}," '.version' box.json)\"\n",[46,129,131,134,136,138,140,143,146,149,151],{"class":48,"line":130},2,[46,132,133],{"class":67},"mainVersion",[46,135,115],{"class":60},[46,137,118],{"class":56},[46,139,53],{"class":52},[46,141,142],{"class":56}," show main:box.json ",[46,144,145],{"class":60},"|",[46,147,148],{"class":52}," jq",[46,150,124],{"class":123},[46,152,153],{"class":56}," '.version')\"\n",[155,156,157],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":42,"searchDepth":130,"depth":130,"links":159},[],"2026-09-18T10:44:03-04:00","This is an interesting one I learned while setting up a \u002Fdraft-gitlab-release skill. Since I manually bump version numbers in this project, it's important to compare the live version number first, so I don't accidentally double-bump the version number on development.",false,"md",{},true,"\u002Fposts\u002Fgit-show-file-from-branch",{"title":5,"description":161},"posts\u002Fgit-show-file-from-branch",[53,170],"til","HlkY7DBiU3fkDzkuOLa1jpn9U3WA4oW-pdSloTTDTDQ",1793891606389]