Our great sponsors
-
Git
Git Source Code Mirror - This is a publish-only repository but pull requests can be turned into patches to the mailing list via GitGitGadget (https://gitgitgadget.github.io/). Please follow Documentation/SubmittingPatches procedure for any of your improvements.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
GitExtensions
Git Extensions is a standalone UI tool for managing git repositories. It also integrates with Windows Explorer and Microsoft Visual Studio (2015/2017/2019).
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
> which branch on a remote is considered the default
That part is actually covered by "the default branch in newly created repositories". There are two different places where its done:
- This is the one you probably mean: [1]
- This is an obscure feature: [2]. A Stack Overflow comment [3] calls it "one of the abandoned experiments that were being done before the concept of a remote was invented".
Both of the places use function git_default_branch_name from refs.c [4], which uses config variable `init.defaultBranch` I've mentioned above.
[1] https://github.com/git/git/blob/v2.43.0/remote.c#L2380-L2383
[2] https://github.com/git/git/blob/v2.43.0/remote.c#L328-L338
[3] https://stackoverflow.com/a/54132016/1083697
[4] https://github.com/git/git/blob/v2.43.0/refs.c#L671-L705
The branch_ref.name prints "refs/remotes/origin/test" but git status says "HEAD detached at origin/test"
So I'm probably feeding the wrong thing into repo.checkout, but I'm honestly not sure what else it should be.
Funnily enough, git itself tries to do the right thing if pulled in a detached head state:
From https://github.com/testorg/example
It actually does but it's very much in alpha/active development (under the umbrella of OpenSSF with the intent of being integrated into mainline git eventually).
https://github.com/gittuf/gittuf
I agree that git is almost asking you to juggle commits.
My preference is to use temporary branches and cherry-picking instead of stashing; I mostly use a gui* to work with git so it is easy to select the two or three commits to cherry-picking or see visually if an interactive rebase would work.
* https://gitextensions.github.io/