git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Feature request: git status --branch-only

From
Ondra Medek <xmedeko@gmail.com>
Date
Nov 14, 2023, 10:16 UTC
Message-ID
<CAJsoDaFX7YdncsTy7UsjxaM1GCKs36-H5RhJ6kzgBUFBJyoGZQ@mail.gmail.com>

Hello, I am working on a tol which should fetch changes from a remote repository on a user click. I want to limit fetch on the current remote tracking branch (something like "origin/master"), but surprisingly, it's hard to get it for all corner cases like a fresh clone of an empty repository or detached head, etc. E.g see this SO thread https://stackoverflow.com/questions/171550/find-out-which-remote-branch-a-local-branch-is-tracking/52896538

The most reliable way for me is to call
git status -b --no-ahead-behind --porcelain=v2

and parse the "# branch.upstream" line output. However, it is a bit slow on large repos and yields unused output for me. So, I propose a new switch "git status --branch-only" which would output branch status only.

Note: workaround is to specify some non-existing directory, like
git status -b --no-ahead-behind --porcelain=v2 .this-dir-does-not-exists

Thanks Ondra Medek

Next: Phillip Wood
Message 1 of 7 in “Feature request: git status --branch-only”
  1. Ondra MedekNov 14, 2023
  2. Phillip WoodNov 14, 2023
  3. Ondra MedekNov 14, 2023
  4. Phillip WoodNov 14, 2023
  5. Ondra MedekNov 14, 2023
  6. Jeff KingNov 14, 2023
  7. phillip.wood123@gmail.comNov 16, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.