for-each-ref

NAME

git-for-each-ref - Output information on each refgit-for-each-ref - 各参照に関する情報を出力する

SYNOPSIS概要

git for-each-ref [--count=<count>] [--shell|--perl|--python|--tcl]
		   [(--sort=<key>)…​] [--format=<format>] [<pattern>…​]
		   [--points-at=<object>]
		   (--merged[=<object>] | --no-merged[=<object>])
		   [--contains[=<object>]] [--no-contains[=<object>]]

DESCRIPTION説明

Iterate over all refs that match <pattern> and show them according to the given <format>, after sorting them according to the given set of <key>. If <count> is given, stop after showing that many refs. The interpolated values in <format> can optionally be quoted as string literals in the specified host language allowing their direct evaluation in that language.指定されたセットに従ってそれらをソートした後<pattern>、一致するすべての参照を繰り返し、指定されたとおりにそれらを表示します。もし与えられたら、たくさんの文献を見せてから止めなさい。内挿された値は、指定されたホスト言語で文字列リテラルとして引用符で囲むことができ、その言語で直接評価することができます。<format><key><count><format>

OPTIONSオプション

<pattern>…​ <パターン>…

If one or more patterns are given, only refs are shown that match against at least one pattern, either using fnmatch(3) or literally, in the latter case matching completely or from the beginning up to a slash.1つ以上のパターンが与えられた場合、fnmatch(3)を使用するか文字通りのいずれかで、少なくとも1つのパターンと一致する参照のみが表示されます。後者の場合、完全一致または最初からスラッシュまで一致します。

--count=<count> --count = <カウント>

By default the command shows all refs that match <pattern>. This option makes it stop after showing that many refs.デフォルトでは、このコマンドは一致するすべての参照を表示します<pattern>。このオプションは、多くの参照を表示した後に停止します。

--sort=<key> --sort = <key>

A field name to sort on. Prefix - to sort in descending order of the value. When unspecified, refname is used. You may use the --sort=<key> option multiple times, in which case the last key becomes the primary key.並べ替えるフィールド名。-値の降順でソートするためのプレフィックス。指定しない場合refnameは、が使用されます。--sort = <key>オプションを複数回使用することができます。その場合、最後のキーが主キーになります。

--format=<format> --format = <フォーマット>

A string that interpolates %(fieldname) from a ref being shown and the object it points at. If fieldname is prefixed with an asterisk (*) and the ref points at a tag object, use the value for the field in the object which the tag object refers to (instead of the field in the tag object). When unspecified, <format> defaults to %(objectname) SPC %(objecttype) TAB %(refname). It also interpolates %% to %, and %xx where xx are hex digits interpolates to character with hex code xx; for example %00 interpolates to %%BODY%% (NUL), %09 to \t (TAB) and %0a to \n (LF).%(fieldname)表示されている参照とそれが指すオブジェクトから補間する文字列。のfieldname前にアスタリスク(*)が付いていて、refがタグオブジェクトを指している場合は、(タグオブジェクト内のフィールドの代わりに)そのタグオブジェクトが参照するオブジェクト内のフィールドの値を使用します。指定しない場合、<format>デフォルトはになり%(objectname) SPC %(objecttype) TAB %(refname)ます。また、補間%%%、そして%xxどこxx進数字が進コードを持つ文字に補間していますxx。例えば%00に対して補間

(NUL)%09\t(TAB)と%0a\n(LF)。

--color[=<when>] --color [= <when>]

Respect any colors specified in the --format option. The <when> field must be one of always, never, or auto (if <when> is absent, behave as if always was given).--formatオプションで指定された色を尊重してください。<when>フィールドは次のいずれかでなければならないalwaysneverまたはauto(場合は<when>存在しない、かのように動作always与えられました)。

--shell - シェル
--perl
--python
--tcl

If given, strings that substitute %(fieldname) placeholders are quoted as string literals suitable for the specified host language. This is meant to produce a scriptlet that can directly be `eval`ed.指定された場合、%(fieldname)プレースホルダを置き換える文字列は、指定されたホスト言語に適した文字列リテラルとして引用されます。これは直接評価できるスクリプトレットを作成するためのものです。

--points-at=<object> --points-at = <オブジェクト>

Only list refs which points at the given object.与えられたオブジェクトを指し示す参照のみをリストします。

--merged[=<object>] --merged [= <オブジェクト>]

Only list refs whose tips are reachable from the specified commit (HEAD if not specified), incompatible with --no-merged.指定されたコミット(指定されていない場合はHEAD)から到達可能なヒントを持つ参照だけを一覧表示し--no-mergedます。互換性はありません。

--no-merged[=<object>] --no-merged [= <オブジェクト>]

Only list refs whose tips are not reachable from the specified commit (HEAD if not specified), incompatible with --merged.指定されたコミット(指定されていない場合はHEAD)から到達できないヒントを持つrefだけを一覧表示し--mergedます。互換性はありません。

--contains[=<object>] --contains [= <オブジェクト>]

Only list refs which contain the specified commit (HEAD if not specified).指定されたコミットを含む参照のみを一覧表示します(指定されていない場合はHEAD)。

--no-contains[=<object>] --no-contains [= <オブジェクト>]

Only list refs which don’t contain the specified commit (HEAD if not specified).指定されたコミットを含まない参照のみを一覧表示します(指定されていない場合はHEAD)。

--ignore-case

Sorting and filtering refs are case insensitive.参照のソートとフィルタリングでは大文字と小文字が区別されません。

FIELD NAMESフィールド名

Various values from structured fields in referenced objects can be used to interpolate into the resulting output, or as sort keys.参照オブジェクト内の構造化フィールドからのさまざまな値を使用して、結果の出力に内挿したり、ソートキーとして使用することができます。

For all objects, the following names can be used:すべてのオブジェクトに対して、以下の名前を使用できます。

refname

The name of the ref (the part after $GIT_DIR/). For a non-ambiguous short name of the ref append :short. The option core.warnAmbiguousRefs is used to select the strict abbreviation mode. If lstrip=<N> (rstrip=<N>) is appended, strips <N> slash-separated path components from the front (back) of the refname (e.g. %(refname:lstrip=2) turns refs/tags/foo into foo and %(refname:rstrip=2) turns refs/tags/foo into refs). If <N> is a negative number, strip as many path components as necessary from the specified end to leave -<N> path components (e.g. %(refname:lstrip=-2) turns refs/tags/foo into tags/foo and %(refname:rstrip=-1) turns refs/tags/foo into refs). When the ref does not have enough components, the result becomes an empty string if stripping with positive <N>, or it becomes the full refname if stripping with negative <N>. Neither is an error.参照の名前($ GIT_DIR /の後の部分)。参照のあいまいさのない短い名前のために追加します:short。オプションcore.warnAmbiguousRefsは、厳密な省略形モードを選択するために使用されます。場合lstrip=<N>rstrip=<N>)が追加され、ストリップは、<N>スラッシュで区切られたパス成分をもしrefnameの前面(背面)から(例えば、%(refname:lstrip=2)オンrefs/tags/foofooし、%(refname:rstrip=2)オンrefs/tags/foorefs)。場合は<N>負の数であり、残すために、指定された端部から必要な数のパスコンポーネントとしてストリップ-<N>パスコンポーネント(例えば、%(refname:lstrip=-2)オンrefs/tags/footags/fooし、%(refname:rstrip=-1)オンrefs/tags/foorefs)refに十分な要素がない場合、正の<N>で削除すると結果は空の文字列になり、負の<N>で削除すると結果は完全なrefnameになります。どちらもエラーではありません。

strip can be used as a synonym to lstrip.stripの同義語として使用できますlstrip

objecttype オブジェクトタイプ

The type of the object (blob, tree, commit, tag).オブジェクトの種類(blobtreecommittag)。

objectsize

The size of the object (the same as git cat-file -s reports). Append :disk to get the size, in bytes, that the object takes up on disk. See the note about on-disk sizes in the CAVEATS section below.オブジェクトのサイズ(git cat-file -s reports と同じ)。:diskオブジェクトがディスク上で占有するサイズをバイト単位で取得するために追加します。CAVEATS以下のセクションのディスク上のサイズに関する注意を参照してください。

objectname オブジェクト名

The object name (aka SHA-1). For a non-ambiguous abbreviation of the object name append :short. For an abbreviation of the object name with desired length append :short=<length>, where the minimum length is MINIMUM_ABBREV. The length may be exceeded to ensure unique object names.オブジェクト名(別名SHA-1)。あいまいでないオブジェクト名の省略形の場合はappendを追加します:short。目的の長さを追加したオブジェクト名の省略形の:short=<length>場合、最小長はMINIMUM_ABBREVです。一意のオブジェクト名を確保するために長さを超えることがあります。

deltabase デルタベース

This expands to the object name of the delta base for the given object, if it is stored as a delta. Otherwise it expands to the null object name (all zeroes).デルタとして格納されている場合、これは指定されたオブジェクトのデルタベースのオブジェクト名に展開されます。それ以外の場合は、nullオブジェクト名(すべてゼロ)に展開されます。

upstream 上流の

The name of a local ref which can be considered “upstream” from the displayed ref. Respects :short, :lstrip and :rstrip in the same way as refname above. Additionally respects :track to show "[ahead N, behind M]" and :trackshort to show the terse version: ">" (ahead), "<" (behind), "<>" (ahead and behind), or "=" (in sync). :track also prints "[gone]" whenever unknown upstream ref is encountered. Append :track,nobracket to show tracking information without brackets (i.e "ahead N, behind M").表示されている参照から「上流」と見なすことができるローカル参照の名前。尊重:short:lstripおよび:rstripと同様にrefname上記の。さらに:track"[ahead N、behind M]"と:trackshort簡潔なバージョンを表示することを尊重します。 ">"(ahead)、 "<"(behind)、 "<>"(前後)、または "="(in)同期します。:trackまた、未知のアップストリームのrefが見つかったときはいつでも "[gone]"を表示します。:track,nobracket角括弧なしで追跡情報を表示するように追加します(すなわち、「N前方」、「M後方」)。

For any remote-tracking branch %(upstream), %(upstream:remotename) and %(upstream:remoteref) refer to the name of the remote and the name of the tracked remote ref, respectively. In other words, the remote-tracking branch can be updated explicitly and individually by using the refspec %(upstream:remoteref):%(upstream) to fetch from %(upstream:remotename).任意のリモート追跡ブランチのための%(upstream)%(upstream:remotename)および%(upstream:remoteref)それぞれ、遠隔の名前と追跡遠隔REFの名前を指します。つまり、refspec %(upstream:remoteref):%(upstream)を使って取得することで、リモートトラッキングブランチを明示的かつ個別に更新できます%(upstream:remotename)

Has no effect if the ref does not have tracking information associated with it. All the options apart from nobracket are mutually exclusive, but if used together the last option is selected.参照に追跡情報が関連付けられていない場合、効果はありません。それ以外のすべてのオプションnobracketは相互に排他的ですが、一緒に使用された場合は最後のオプションが選択されます。

push 押す

The name of a local ref which represents the @{push} location for the displayed ref. Respects :short, :lstrip, :rstrip, :track, :trackshort, :remotename, and :remoteref options as upstream does. Produces an empty string if no @{push} ref is configured.@{push}表示されている参照の場所を表すローカル参照の名前。尊重し:short:lstrip:rstrip:track:trackshort:remotename、および:remoterefオプションとしてupstream行います。@{push}参照が設定されていない場合は、空の文字列を生成します。

HEAD

* if HEAD matches current ref (the checked out branch), ' ' otherwise.* HEADが現在の参照(チェックアウトされたブランチ)と一致する場合はそうでなければ ''。

color

Change output color. Followed by :<colorname>, where color names are described under Values in the "CONFIGURATION FILE" section of git-config[1]. For example, %(color:bold red).出力色を変更してください。続いて:<colorname>、色名はgit-config [1]の "設定ファイル"セクションの値の下に記述されています。たとえば、%(color:bold red)

align 並べる

Left-, middle-, or right-align the content between %(align:…​) and %(end). The "align:" is followed by width=<width> and position=<position> in any order separated by a comma, where the <position> is either left, right or middle, default being left and <width> is the total length of the content with alignment. For brevity, the "width=" and/or "position=" prefixes may be omitted, and bare <width> and <position> used instead. For instance, %(align:<width>,<position>). If the contents length is more than the width then no alignment is performed. If used with --quote everything in between %(align:…​) and %(end) is quoted, but if nested then only the topmost level performs quoting.内容を%(align:…)と%(end)の間で左、中央、または右揃えにします。「整列」が続くwidth=<width>position=<position>カンマで区切ら任意の順序で<position>、左右または中央、左されるデフォルトのいずれかであり、<width>アライメントとコンテンツの全長です。簡潔にするために、 "width ="または "position ="の接頭辞を省略し、代わりに<width>と<position>を使用することができます。たとえば%(align:<width>,<position>)。内容の長さが幅よりも大きい場合、配置は実行されません。--quote%(align:…)と%(end)の間にあるものすべてと一緒に使用された場合は引用符で囲まれますが、ネストされている場合は最上位レベルのみが引用符を実行します。

if もし

Used as %(if)…​%(then)…​%(end) or %(if)…​%(then)…​%(else)…​%(end). If there is an atom with value or string literal after the %(if) then everything after the %(then) is printed, else if the %(else) atom is used, then everything after %(else) is printed. We ignore space when evaluating the string before %(then), this is useful when we use the %(HEAD) atom which prints either "*" or " " and we want to apply the if condition only on the HEAD ref. Append ":equals=<string>" or ":notequals=<string>" to compare the value between the %(if:…​) and %(then) atoms with the given string.%(if)…%(then)…%(end)または%(if)…%(then)…%(else)…%(end)として使用されます。%(if)の後に値または文字列リテラルを持つアトムがある場合は%(then)の後のすべてが表示され、それ以外の場合は%(else)アトムが使用される場合は%(else)の後のすべてが出力されます。%(then)の前の文字列を評価するときにスペースを無視します。これは、 "*"または ""のいずれかを出力する%(HEAD)アトムを使用し、HEAD参照にのみif条件を適用したい場合に役立ちます。":equals = <文字列>"または ":notequals = <文字列>"を追加して、%(if:…)と%(then)の間の値を指定された文字列と比較します。

symref

The ref which the given symbolic ref refers to. If not a symbolic ref, nothing is printed. Respects the :short, :lstrip and :rstrip options in the same way as refname above.与えられたシンボリック参照が参照する参照。シンボリックリファレンスでない場合は、何も表示されません。上記と同じ方法で:short:lstripおよび:rstripオプションを尊重しますrefname

In addition to the above, for commit and tag objects, the header field names (tree, parent, object, type, and tag) can be used to specify the value in the header field.上記に加えて、のコミットとタグオブジェクト、ヘッダフィールド名(treeparentobjecttype、およびtag)は、ヘッダフィールドの値を指定するために使用することができます。

For commit and tag objects, the special creatordate and creator fields will correspond to the appropriate date or name-email-date tuple from the committer or tagger fields depending on the object type. These are intended for working on a mix of annotated and lightweight tags.commitオブジェクトとtagオブジェクトの場合、special creatordatecreatorfieldsは、オブジェクト型に応じてcommitteror taggerフィールドからの適切な日付またはname-email-dateタプルに対応します。これらは、注釈付きタグと軽量タグの組み合わせで作業することを目的としています。

Fields that have name-email-date tuple as its value (author, committer, and tagger) can be suffixed with name, email, and date to extract the named component.(その値として名前メール日付タプルを持つフィールドauthorcommitter、およびtagger)は、接尾辞することができnameemailおよびdate名前の成分を抽出します。

The complete message in a commit and tag object is contents. Its first line is contents:subject, where subject is the concatenation of all lines of the commit message up to the first blank line. The next line is contents:body, where body is all of the lines after the first blank line. The optional GPG signature is contents:signature. The first N lines of the message is obtained using contents:lines=N. Additionally, the trailers as interpreted by git-interpret-trailers[1] are obtained as trailers (or by using the historical alias contents:trailers). Non-trailer lines from the trailer block can be omitted with trailers:only. Whitespace-continuations can be removed from trailers so that each trailer appears on a line by itself with its full content with trailers:unfold. Both can be used together as trailers:unfold,only.コミットおよびタグオブジェクト内の完全なメッセージはcontentsです。最初の行はcontents:subject、subjectがコミットメッセージの最初の空白行までのすべての行の連結です。次の行はcontents:body、bodyは最初の空白行の後のすべての行です。オプションのGPG署名はcontents:signatureです。Nメッセージの最初の行はを使って取得されcontents:lines=Nます。さらに、git-interpret-trailers [1]によって解釈されたトレーラーは、としてtrailers(あるいは歴史的別名を使ってcontents:trailers)取得されます。トレーラブロックからの非トレーラ行はと一緒に省略することができますtrailers:only。空白の継続は、各トレーラーがその完全な内容と共に単独で行に現れるように、トレーラーから削除することができますtrailers:unfold。両方とも一緒に使用することができますtrailers:unfold,only

For sorting purposes, fields with numeric values sort in numeric order (objectsize, authordate, committerdate, creatordate, taggerdate). All other fields are used to sort in their byte-value order.仕分けの目的のために、(ソート番号順に数値を持つフィールドobjectsizeauthordatecommitterdatecreatordatetaggerdate)。他のすべてのフィールドは、それらのバイト値順にソートするために使用されます。

There is also an option to sort by versions, this can be done by using the fieldname version:refname or its alias v:refname.バージョンでソートするオプションもあります。これはフィールド名version:refnameまたはその別名を使用して行うことができますv:refname

In any case, a field name that refers to a field inapplicable to the object referred by the ref does not cause an error. It returns an empty string instead.いずれにせよ、参照によって参照されるオブジェクトに適用できないフィールドを参照するフィールド名は、エラーにはなりません。代わりに空の文字列を返します。

As a special case for the date-type fields, you may specify a format for the date by adding : followed by date format name (see the values the --date option to git-rev-list[1] takes).date-typeフィールドの特別な場合として、:日付フォーマット名を追加して日付のフォーマットを指定することができます(git-rev-list [1]--dateオプションがとる値を参照してください)。

Some atoms like %(align) and %(if) always require a matching %(end). We call them "opening atoms" and sometimes denote them as %($open).%(align)や%(if)のようないくつかのアトムは、常に一致する%(end)を必要とします。我々はそれらを「開口原子」と呼び、時にはそれらを%($ open)と表します。

When a scripting language specific quoting is in effect, everything between a top-level opening atom and its matching %(end) is evaluated according to the semantics of the opening atom and only its result from the top-level is quoted.スクリプト言語固有の引用符が有効な場合、トップレベルの開始アトムとそれに一致する%(end)の間のすべてが、オープニングアトムの意味に従って評価され、トップレベルからの結果のみが引用符で囲まれます。

EXAMPLES

An example directly producing formatted text. Show the most recent 3 tagged commits:書式付きテキストを直接生成する例 最新の3つのタグ付きコミットを表示:

#!/bin/sh
git for-each-ref --count=3 --sort='-*authordate' \
--format='From: %(*authorname) %(*authoremail)
Subject: %(*subject)
Date: %(*authordate)
Ref: %(*refname)
%(*body)
' 'refs/tags'

A simple example showing the use of shell eval on the output, demonstrating the use of --shell. List the prefixes of all heads:出力にshell evalを使用する簡単な例。 - shellの使用方法を示しています。すべてのヘッドの接頭辞を一覧表示します。

#!/bin/sh
git for-each-ref --shell --format="ref=%(refname)" refs/heads | \
while read entry
do
	eval "$entry"
	echo `dirname $ref`
done

A bit more elaborate report on tags, demonstrating that the format may be an entire script:タグに関するもう少し詳細なレポート。形式はスクリプト全体である可能性があることを示しています。

#!/bin/sh
fmt='
	r=%(refname)
	t=%(*objecttype)
	T=${r#refs/tags/}
	o=%(*objectname)
	n=%(*authorname)
	e=%(*authoremail)
	s=%(*subject)
	d=%(*authordate)
	b=%(*body)
	kind=Tag
	if test "z$t" = z
	then
		# could be a lightweight tag
		t=%(objecttype)
		kind="Lightweight tag"
		o=%(objectname)
		n=%(authorname)
		e=%(authoremail)
		s=%(subject)
		d=%(authordate)
		b=%(body)
	fi
	echo "$kind $T points at a $t object $o"
	if test "z$t" = zcommit
	then
		echo "The commit was authored by $n $e
at $d, and titled
    $s
Its message reads as:
"
		echo "$b" | sed -e "s/^/    /"
		echo
	fi
'
eval=`git for-each-ref --shell --format="$fmt" \
	--sort='*objecttype' \
	--sort=-taggerdate \
	refs/tags`
eval "$eval"

An example to show the usage of %(if)…​%(then)…​%(else)…​%(end). This prefixes the current branch with a star.%(if)…%(then)…%(else)…%(end)の使い方を示す例。これは現在の枝に星印を付けます。

git for-each-ref --format="%(if)%(HEAD)%(then)* %(else)  %(end)%(refname:short)" refs/heads/

An example to show the usage of %(if)…​%(then)…​%(end). This prints the authorname, if present.%(if)…%(then)…%(end)の使い方を示す例。もしあれば、これは著者名を表示します。

git for-each-ref --format="%(refname)%(if)%(authorname)%(then) Authored by: %(authorname)%(end)"

CAVEATS警告

Note that the sizes of objects on disk are reported accurately, but care should be taken in drawing conclusions about which refs or objects are responsible for disk usage. The size of a packed non-delta object may be much larger than the size of objects which delta against it, but the choice of which object is the base and which is the delta is arbitrary and is subject to change during a repack.ディスク上のオブジェクトのサイズは正確に報告されていますが、どの参照またはオブジェクトがディスクの使用に責任があるかについての結論を引き出す際には注意が必要です。パックされた非デルタオブジェクトのサイズは、それに対してデルタするオブジェクトのサイズよりはるかに大きくなる可能性がありますが、どのオブジェクトがベースでどれがデルタであるかの選択は任意であり、再パック中に変更されます。

Note also that multiple copies of an object may be present in the object database; in this case, it is undefined which copy’s size or delta base will be reported.オブジェクトデータベースには、オブジェクトの複数のコピーが存在する可能性があることにも注意してください。この場合、どのコピーのサイズまたはデルタベースが報告されるかは未定義です。

SEE ALSO関連項目

git-show-ref[1]git-show-ref [1]

GIT

Part of the git[1] suite一部のgit [1]スイート

関連記事

スポンサーリンク

ペンギンの種類

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る