gc

NAME

git-gc - Cleanup unnecessary files and optimize the local repositorygit-gc - 不要なファイルを整理してローカルリポジトリを最適化する

SYNOPSIS概要

git gc [--aggressive] [--auto] [--quiet] [--prune=<date> | --no-prune] [--force] [--keep-largest-pack]

DESCRIPTION説明

Runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance), removing unreachable objects which may have been created from prior invocations of git add, packing refs, pruning reflog, rerere metadata or stale working trees. May also update ancillary indexes such as the commit-graph.現在のリポジトリ内で、ファイルリビジョンの圧縮(ディスク容量の削減とパフォーマンスの向上)、以前のgit addの呼び出しで作成された到達不能なオブジェクトの削除、refのパッキング、reflogの整理、メタデータの再作成などのハウスキーピングタスクを実行します。働く木が古くなっています。commit-graphなどの補助インデックスも更新される可能性があります。

Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.ユーザーは、このタスクを各リポジトリー内で定期的に実行して、良好なディスク・スペース使用率と良好な操作パフォーマンスを維持することをお勧めします。

Some git commands may automatically run git gc; see the --auto flag below for details. If you know what you’re doing and all you want is to disable this behavior permanently without further considerations, just do:いくつかのgitコマンドは自動的にgit gcを実行します。詳細は--auto下記の旗を見てください。自分のしていることがわかっていて、さらに考慮せずにこの動作を永久に無効にすることだけを望んでいる場合は、次のようにしてください。

$ git config --global gc.auto 0

OPTIONSオプション

--aggressive - 積極的

Usually git gc runs very quickly while providing good disk space utilization and performance. This option will cause git gc to more aggressively optimize the repository at the expense of taking much more time. The effects of this optimization are persistent, so this option only needs to be used occasionally; every few hundred changesets or so.通常、git gcは非常に速く動作しますが、ディスクスペースの利用率とパフォーマンスは良好です。このオプションを使用すると、git gcはもっと時間をかけてリポジトリをより積極的に最適化します。この最適化の効果は持続的なので、このオプションは時折使用する必要があるだけです。数百チェンジセットかそこらです。

--auto - オート

With this option, git gc checks whether any housekeeping is required; if not, it exits without performing any work. Some git commands run git gc --auto after performing operations that could create many loose objects. Housekeeping is required if there are too many loose objects or too many packs in the repository.このオプションを指定すると、git gcはハウスキーピングが必要かどうかをチェックします。そうでなければ、何もしないで終了します。いくつかのgitコマンドはgit gc --auto、ルーズオブジェクトをたくさん作成する可能性のある操作を実行した後に実行されます。リポジトリ内に存在するオブジェクトが多すぎる、またはパックが多すぎる場合は、ハウスキーピングが必要です。

If the number of loose objects exceeds the value of the gc.auto configuration variable, then all loose objects are combined into a single pack using git repack -d -l. Setting the value of gc.auto to 0 disables automatic packing of loose objects.緩いオブジェクトの数がgc.auto構成変数の値を超えると、すべての緩いオブジェクトはを使用して単一のパックにまとめられますgit repack -d -l。値gc.autoを0に設定すると、固定されていないオブジェクトの自動パッキングは無効になります。

If the number of packs exceeds the value of gc.autoPackLimit, then existing packs (except those marked with a .keep file or over gc.bigPackThreshold limit) are consolidated into a single pack by using the -A option of git repack. If the amount of memory is estimated not enough for git repack to run smoothly and gc.bigPackThreshold is not set, the largest pack will also be excluded (this is the equivalent of running git gc with --keep-base-pack). Setting gc.autoPackLimit to 0 disables automatic consolidation of packs.パック数がの値を超えると、git repackのオプションを使用して、gc.autoPackLimit既存のパック(.keepファイルまたはgc.bigPackThreshold上限を超えてマークされているものを除く)が単一のパックに統合され-Aます。メモリの量がスムーズに動作するのに十分ではないと推定され、設定されていない場合、最大のパックも除外されます(これはwith withと同等です)。0に設定すると、パックの自動統合は無効になります。git repackgc.bigPackThresholdgit gc--keep-base-packgc.autoPackLimit

If houskeeping is required due to many loose objects or packs, all other housekeeping tasks (e.g. rerere, working trees, reflog…​) will be performed as well.たくさんのばらばらの物や荷物のために整理が必要な場合は、他のすべての整理作業(たとえば、rerere、working trees、reflogなど)も実行されます。

--prune=<date> --prune = <日付>

Prune loose objects older than date (default is 2 weeks ago, overridable by the config variable gc.pruneExpire). --prune=all prunes loose objects regardless of their age and increases the risk of corruption if another process is writing to the repository concurrently; see "NOTES" below. --prune is on by default.日付より古いルーズオブジェクトを整理します(デフォルトは2週間前、config変数で上書き可能gc.pruneExpire)。--prune =すべてのプルーニングは、年齢に関係なくオブジェクトを解放し、別のプロセスが同時にリポジトリに書き込んでいると破損のリスクを高めます。下記の「注意」を参照してください。--pruneはデフォルトでオンになっています。

--no-prune - プルーン

Do not prune any loose objects.ゆったりとしたものを取り除かないでください。

--quiet - 静か

Suppress all progress reports.進捗レポートをすべて抑制します。

--force - 力

Force git gc to run even if there may be another git gc instance running on this repository.このリポジトリでgit gc別のgit gcインスタンスが実行されている可能性がある場合でも実行するよう強制します。

--keep-largest-pack - キープ最大パック

All packs except the largest pack and those marked with a .keep files are consolidated into a single pack. When this option is used, gc.bigPackThreshold is ignored.最大のパックと.keepファイルでマークされたものを除くすべてのパックは単一のパックに統合されます。このオプションを使用すると、gc.bigPackThreshold無視されます。

CONFIGURATION設定

The optional configuration variable gc.reflogExpire can be set to indicate how long historical entries within each branch’s reflog should remain available in this repository. The setting is expressed as a length of time, for example 90 days or 3 months. It defaults to 90 days.オプションの設定変数gc.reflogExpireは、各ブランチのreflog内の履歴エントリがこのリポジトリで利用可能であり続ける期間を示すために設定できます。設定は、90日または3か月などの期間として表されます。デフォルトは90日です。

The optional configuration variable gc.reflogExpireUnreachable can be set to indicate how long historical reflog entries which are not part of the current branch should remain available in this repository. These types of entries are generally created as a result of using git commit --amend or git rebase and are the commits prior to the amend or rebase occurring. Since these changes are not part of the current project most users will want to expire them sooner. This option defaults to 30 days.オプションの設定変数gc.reflogExpireUnreachableは、現在のブランチの一部ではない履歴reflogエントリがこのリポジトリで利用可能であり続ける期間を示すために設定することができます。これらの種類のエントリーは一般的にgit commit --amendまたはの使用の結果として作成されgit rebase、修正またはリベースが行われる前のコミットです。これらの変更は現在のプロジェクトの一部ではないので、ほとんどのユーザーはそれらをより早く期限切れにしたいでしょう。このオプションのデフォルトは30日です。

The above two configuration variables can be given to a pattern. For example, this sets non-default expiry values only to remote-tracking branches:上記の2つの設定変数をパターンに与えることができます。たとえば、これはデフォルト以外の有効期限値をリモート追跡ブランチにのみ設定します。

[gc "refs/remotes/*"]
	reflogExpire = never
	reflogExpireUnreachable = 3 days

The optional configuration variable gc.rerereResolved indicates how long records of conflicted merge you resolved earlier are kept. This defaults to 60 days.オプションの構成変数gc.rerereResolvedは、以前に解決した競合マージのレコードが保持される期間を示します。デフォルトは60日です。

The optional configuration variable gc.rerereUnresolved indicates how long records of conflicted merge you have not resolved are kept. This defaults to 15 days.オプションの構成変数gc.rerereUnresolvedは、競合したマージの解決していないレコードが保持される期間を示します。デフォルトは15日です。

The optional configuration variable gc.packRefs determines if git gc runs git pack-refs. This can be set to "notbare" to enable it within all non-bare repos or it can be set to a boolean value. This defaults to true.オプションの設定変数gc.packRefsgit gcgit pack-refsを実行するかどうかを決定します。ベア以外のすべてのリポジトリ内で有効にするには、これを "notbare"に設定するか、ブール値に設定します。これはデフォルトでtrueです。

The optional configuration variable gc.writeCommitGraph determines if git gc should run git commit-graph write. This can be set to a boolean value. This defaults to false.オプションの設定変数gc.writeCommitGraphgit gcgit commit-graph writeを実行するかどうかを決定します。これはブール値に設定できます。デフォルトはfalseです。

The optional configuration variable gc.aggressiveWindow controls how much time is spent optimizing the delta compression of the objects in the repository when the --aggressive option is specified. The larger the value, the more time is spent optimizing the delta compression. See the documentation for the --window option in git-repack[1] for more details. This defaults to 250.オプションの設定変数gc.aggressiveWindowは、--aggressiveオプションが指定されているときにリポジトリ内のオブジェクトのデルタ圧縮を最適化するのに費やす時間を制御します。値が大きいほど、デルタ圧縮の最適化に時間がかかります。詳細はgit- repack [1]の--windowオプションに関するドキュメントを参照してください。デフォルトは250です。

Similarly, the optional configuration variable gc.aggressiveDepth controls --depth option in git-repack[1]. This defaults to 50.同様に、オプションの設定変数gc.aggressiveDepthgit- repack [1]の --depthオプションを制御します。デフォルトは50です。

The optional configuration variable gc.pruneExpire controls how old the unreferenced loose objects have to be before they are pruned. The default is "2 weeks ago".オプションの設定変数gc.pruneExpireは、整理される前に参照されていない緩いオブジェクトがどれくらい古い必要があるかを制御します。デフォルトは「2週間前」です。

Optional configuration variable gc.worktreePruneExpire controls how old a stale working tree should be before git worktree prune deletes it. Default is "3 months ago".オプションの設定変数gc.worktreePruneExpireは、古い作業ツリーがgit worktree prune削除されるまでの古い保存期間を制御します。デフォルトは「3ヶ月前」です。

NOTESノート

git gc tries very hard not to delete objects that are referenced anywhere in your repository. In particular, it will keep not only objects referenced by your current set of branches and tags, but also objects referenced by the index, remote-tracking branches, refs saved by git filter-branch in refs/original/, or reflogs (which may reference commits in branches that were later amended or rewound). If you are expecting some objects to be deleted and they aren’t, check all of those locations and decide whether it makes sense in your case to remove those references.git gcはあなたのリポジトリのどこかで参照されているオブジェクトを削除しないように非常に努力します。特に、現在のブランチやタグのセットによって参照されているオブジェクトだけでなく、インデックスによって参照されているオブジェクト、リモートトラッキングブランチ、git filter-branchによってrefs / original /に保存されているリファレンス、またはreflogs(参照は後で修正または巻き戻されたブランチでコミットされます。いくつかのオブジェクトが削除されることを期待していても、そうではない場合は、それらの場所をすべて確認し、それらの参照を削除するのが妥当かどうかを判断してください。

On the other hand, when git gc runs concurrently with another process, there is a risk of it deleting an object that the other process is using but hasn’t created a reference to. This may just cause the other process to fail or may corrupt the repository if the other process later adds a reference to the deleted object. Git has two features that significantly mitigate this problem:一方、git gcが他のプロセスと同時に実行されると、他のプロセスが使用しているが参照を作成していないオブジェクトを削除する危険性があります。他のプロセスが後で削除されたオブジェクトへの参照を追加した場合、これは他のプロセスが失敗するか、リポジトリを破損させる可能性があります。Gitには、この問題を大幅に軽減する2つの機能があります。

  1. Any object with modification time newer than the --prune date is kept, along with everything reachable from it.--prune日付よりも新しい修正時刻を持つオブジェクトは、そこから到達可能なすべてのものと共に保持されます。

  2. Most operations that add an object to the database update the modification time of the object if it is already present so that #1 applies.データベースにオブジェクトを追加するほとんどの操作は、オブジェクトがすでに存在する場合はその変更時刻を更新するので、#1が適用されます。

However, these features fall short of a complete solution, so users who run commands concurrently have to live with some risk of corruption (which seems to be low in practice) unless they turn off automatic garbage collection with git config gc.auto 0.しかし、これらの機能は完全な解決策にはなりません。そのため、コマンドを同時に実行するユーザーは、git config gc.auto 0で自動ガベージコレクションをオフにしない限り、何らかの破損のリスク(実際には低いと思われます)に耐える必要があります

HOOKSフック

The git gc --auto command will run the pre-auto-gc hook. See githooks[5] for more information.git gcを--autoコマンドが実行され、プリ自動GCフックを。詳細についてはgithooks [5]を参照してください。

SEE ALSO関連項目

git-prune[1] git-reflog[1] git-repack[1] git-rerere[1]git-prune [1] git-reflog [1] git-repack [1] git-rerere [1]

GIT

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

関連記事

スポンサーリンク

ペンギンの種類

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

上に戻る