Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git for-each-ref with <pattern> returns nothing

Tags:

git

git-branch

git branch --list 'hotfix' returns a list of branches that contain the word 'hotfix' inside the branch name, whereas git for-each-ref --format='%(authorname)' 'hotfix' return nothing, not even /n symbol

like image 446
JohnIdlewood Avatar asked Oct 28 '25 01:10

JohnIdlewood


1 Answers

git branch is looking (by default) at just the branches - the refs in refs/heads - so it lets you use patterns that match just the "branch name" (e.g. some-hotfix which is actually shorthand for the full ref name refs/heads/some-hotfix).

for-each-ref is looking at all refs, so it doesn't let you use such patterns. You can use something like refs/heads/*hotfix* if you know that you're only interested in branches (or something like **/*hotfix* if not).

like image 161
Mark Adelsberger Avatar answered Oct 30 '25 16:10

Mark Adelsberger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!