# Determining if your branch is part of a GitHub Stacked PR

DevFeed: [Determining if your branch is part of a GitHub Stacked PR](<https://devfeed.tech/articles/determining-if-your-branch-is-part-of-a-github-stacked-pr-53099.md>)

Original publisher: [Read original article](<https://www.jvt.me/posts/2026/08/26/zsh-stacked-pr/>)

Author: Jamie Tanna

Published: 2026-08-26T14:41:41Z

Content type: tutorial

Language: en

Sources: [Jamie Tanna](<https://devfeed.tech/sources/articles-on-jamie-tanna-software-engineer.md>)

Topics: [GitHub](<https://devfeed.tech/topics/github.md>), [Pull Request](<https://devfeed.tech/topics/pull-request.md>), [Git](<https://devfeed.tech/topics/git.md>), [software-development](<https://devfeed.tech/topics/software-development.md>), [Zsh](<https://devfeed.tech/topics/zsh.md>), [file](<https://devfeed.tech/topics/file.md>), [Repository](<https://devfeed.tech/topics/repository.md>)

Tags: [blogumentation](<https://devfeed.tech/tags/blogumentation.md>), [branch](<https://devfeed.tech/tags/branch.md>), [git](<https://devfeed.tech/tags/git.md>), [github](<https://devfeed.tech/tags/github.md>), [jq](<https://devfeed.tech/tags/jq.md>), [position](<https://devfeed.tech/tags/position.md>), [shell-scripting](<https://devfeed.tech/tags/shell-scripting.md>), [stacked-prs](<https://devfeed.tech/tags/stacked-prs.md>), [sync](<https://devfeed.tech/tags/sync.md>), [zsh](<https://devfeed.tech/tags/zsh.md>)

## AI overview

A post explains how to detect whether the current Git branch belongs to a GitHub stacked pull request and display its position in a zsh prompt. It uses cached stack data and notes that the display can become stale until GitHub's stack synchronization command is run.

## Source excerpt

🤖 This post includes some LLM-derived content 🤖 Since the availability of GitHub's Stacked PRs finally landing for repositories that use a Merge Queue, I've been "kicking the tyres" with some of my contributions to Renovate. They're working mostly well so far, but I'm finding it a bit annoying trying to remember if I'm on a branch that's part of a stack. I'd started wiring this into my zsh config, still using Grml's zsh config as a base, and found it was a bit awkward. I decided to outsource it to Claude Sonnet 5 - cause I guess that's the sort of person I am now? 😅 - and it came out with this: # in case you're working in a Git worktree git_common_dir="$(git rev-parse --git-dir >/dev/null)" stack_file="$git_common_dir/gh-stack" position="$(jq -r --arg b "$(git branch --show-current)" ' .stacks[] | select(.branches[]?.branch == $b) | (.branches | map(.branch)) as $names | ($names | index($b)) as $idx | "\($idx + 1)/\($names | length)" ' "$stack_file" 2>/dev/null | head -n1)" echo "$position" # outputs i.e. `x/y` or `` if not in a stack I end up wiring this into my zsh prompt to show a 🥞 1/3 indicator like so: This works quite nicely, but I've found that it doesn't always stay in sync with GitHub. If a branch has been merged, but you've not yet run gh stack sync, you'll show as still on a stack. However, you can't run gh stack sync without being on a stacked branch, so your cached data may be out-of-sync until that's fixed.