branch

NAME

git-branch - List, create, or delete branchesgit-branch - ブランチの一覧表示、作成、削除

SYNOPSIS概要

git branch [--color[=<when>] | --no-color] [-r | -a]
	[--list] [-v [--abbrev=<length> | --no-abbrev]]
	[--column[=<options>] | --no-column] [--sort=<key>]
	[(--merged | --no-merged) [<commit>]]
	[--contains [<commit]] [--no-contains [<commit>]]
	[--points-at <object>] [--format=<format>] [<pattern>…​]
git branch [--track | --no-track] [-f] <branchname> [<start-point>]
git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
git branch --unset-upstream [<branchname>]
git branch (-m | -M) [<oldbranch>] <newbranch>
git branch (-c | -C) [<oldbranch>] <newbranch>
git branch (-d | -D) [-r] <branchname>…​
git branch --edit-description [<branchname>]

DESCRIPTION説明

If --list is given, or if there are no non-option arguments, existing branches are listed; the current branch will be highlighted with an asterisk. Option -r causes the remote-tracking branches to be listed, and option -a shows both local and remote branches. If a <pattern> is given, it is used as a shell wildcard to restrict the output to matching branches. If multiple patterns are given, a branch is shown if it matches any of the patterns. Note that when providing a <pattern>, you must use --list; otherwise the command is interpreted as branch creation.--listが与えられた場合、またはオプション以外の引数がない場合は、既存のブランチがリストされます。現在のブランチはアスタリスクで強調表示されます。Option -rはリモート追跡ブランチを一覧表示し、option -aはローカルとリモートの両方のブランチを表示します。a <pattern>が与えられると、それをシェルのワイルドカードとして使用して、一致するブランチに出力を制限します。複数のパターンが指定されている場合は、いずれかのパターンに一致すると分岐が表示されます。aを提供するときは<pattern>、あなたが使わなければならないことに注意してください--list。それ以外の場合、コマンドはブランチの作成として解釈されます。

With --contains, shows only the branches that contain the named commit (in other words, the branches whose tip commits are descendants of the named commit), --no-contains inverts it. With --merged, only branches merged into the named commit (i.e. the branches whose tip commits are reachable from the named commit) will be listed. With --no-merged only branches not merged into the named commit will be listed. If the <commit> argument is missing it defaults to HEAD (i.e. the tip of the current branch).With --containsは、名前付きコミットを含むブランチ(つまり、その先端コミットが名前付きコミットの子孫であるブランチ)のみを表示し、--no-containsそれを反転します。では--merged、名前付きコミットにマージされたブランチ(つまり、そのチップコミットが名前付きコミットから到達可能なブランチ)だけがリストされます。で--no-merged唯一の支店は、名前付きにマージされていない表示されますコミット。<commit>引数がない場合は、デフォルトの値HEAD(つまり、現在のブランチの先端)になります。

The command’s second form creates a new branch head named <branchname> which points to the current HEAD, or <start-point> if given.コマンドの2番目の形式は、現在を指す<branchname>という名前の新しいブランチヘッドHEAD、または指定されている場合は<start-point>を作成します。

Note that this will create the new branch, but it will not switch the working tree to it; use "git checkout <newbranch>" to switch to the new branch.これは新しいブランチを作成しますが、作業ツリーをそれに切り替えません。新しいブランチに切り替えるには "git checkout <newbranch>"を使ってください。

When a local branch is started off a remote-tracking branch, Git sets up the branch (specifically the branch.<name>.remote and branch.<name>.merge configuration entries) so that git pull will appropriately merge from the remote-tracking branch. This behavior may be changed via the global branch.autoSetupMerge configuration flag. That setting can be overridden by using the --track and --no-track options, and changed later using git branch --set-upstream-to.ローカルブランチがリモートトラッキングブランチから開始されると、Gitはそのブランチ(特にbranch.<name>.remoteおよびbranch.<name>.merge設定エントリ)をセットアップして、git pullがリモートトラッキングブランチから適切にマージされるようにします。この動作はグローバルbranch.autoSetupMerge設定フラグによって変更されるかもしれません。この設定は--trackand --no-trackオプションを使用して上書きでき、後でを使用して変更できますgit branch --set-upstream-to

With a -m or -M option, <oldbranch> will be renamed to <newbranch>. If <oldbranch> had a corresponding reflog, it is renamed to match <newbranch>, and a reflog entry is created to remember the branch renaming. If <newbranch> exists, -M must be used to force the rename to happen.-m-Mオプション、<oldbranch> <newbranch>に変更されます。<oldbranch>に対応するreflogがある場合は、<newbranch>と一致するように名前が変更され、ブランチの名前変更を記憶するためにreflogエントリが作成されます。<newbranch>が存在する場合は、-Mを使用して名前の変更を強制する必要があります。

The -c and -C options have the exact same semantics as -m and -M, except instead of the branch being renamed it along with its config and reflog will be copied to a new name.オプションはまったく同じ意味を持っているし、代わりに新しい名前にコピーされますその設定とREFLOGと一緒に名前を変更されている枝のを除いて、。-c-C-m-M

With a -d or -D option, <branchname> will be deleted. You may specify more than one branch for deletion. If the branch currently has a reflog then the reflog will also be deleted.-d-Dオプション、<branchname>削除されます。削除用に複数のブランチを指定できます。ブランチに現在reflogがある場合は、reflogも削除されます。

Use -r together with -d to delete remote-tracking branches. Note, that it only makes sense to delete remote-tracking branches if they no longer exist in the remote repository or if git fetch was configured not to fetch them again. See also the prune subcommand of git-remote[1] for a way to clean up all obsolete remote-tracking branches.-r一緒に使用して-d、リモートトラッキングブランチを削除します。リモート追跡ブランチがリモートリポジトリに存在しなくなった場合、またはgit fetchがそれらを再度フェッチしないように設定されている場合にのみ、リモート追跡ブランチを削除することは意味があることに注意してください。廃止されたすべてのリモート追跡ブランチをクリーンアップする方法については、git-remote [1]pruneサブコマンドも参照してください。

OPTIONSオプション

-d
--delete - 削除

Delete a branch. The branch must be fully merged in its upstream branch, or in HEAD if no upstream was set with --track or --set-upstream-to.ブランチを削除する 枝は完全にその上流ブランチにマージし、またはでなければなりませんHEAD何の上流がで設定されていない場合--trackまたは--set-upstream-to

-D

Shortcut for --delete --force.ショートカット--delete --force

--create-reflog

Create the branch’s reflog. This activates recording of all changes made to the branch ref, enabling use of date based sha1 expressions such as "<branchname>@{yesterday}". Note that in non-bare repositories, reflogs are usually enabled by default by the core.logAllRefUpdates config option. The negated form --no-create-reflog only overrides an earlier --create-reflog, but currently does not negate the setting of core.logAllRefUpdates.ブランチのreflogを作成してください。これにより、ブランチ参照に対して行われたすべての変更の記録がアクティブになり、 "<branchname> @ {yesterday}"などの日付ベースのsha1式を使用できるようになります。ベア以外のリポジトリでは、通常、reflogはcore.logAllRefUpdatesconfigオプションによってデフォルトで有効になっています。否定形式--no-create-reflogは、以前の形式をオーバーライドするだけですが、--create-reflog現在の設定を否定するものではありませんcore.logAllRefUpdates

-f
--force - 力

Reset <branchname> to <startpoint>, even if <branchname> exists already. Without -f, git branch refuses to change an existing branch. In combination with -d (or --delete), allow deleting the branch irrespective of its merged status. In combination with -m (or --move), allow renaming the branch even if the new branch name already exists, the same applies for -c (or --copy).<branchname>が既に存在する場合でも、<branchname>を<startpoint>にリセットします。そうでなければ-fgit branchは既存のbranchを変更することを拒否します。-d(または--delete)と組み合わせて、マージされたステータスに関係なくブランチを削除できます。-m(または--move)と組み合わせて、新しいブランチ名がすでに存在している場合でもブランチの名前変更を許可します。-c(または--copy)についても同じことが言えます。

-m
--move - ムーヴ

Move/rename a branch and the corresponding reflog.ブランチとそれに対応するreflogを移動/名前変更します。

-M

Shortcut for --move --force.ショートカット--move --force

-c
--copy - コピー

Copy a branch and the corresponding reflog.ブランチと対応するreflogをコピーしてください。

-C

Shortcut for --copy --force.ショートカット--copy --force

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

Color branches to highlight current, local, and remote-tracking branches. The value must be always (the default), never, or auto.色分けされたブランチは、現在、ローカル、およびリモートトラッキングのブランチを強調表示します。値はalways(デフォルト)、never、またはautoである必要があります。

--no-color - 色なし

Turn off branch colors, even when the configuration file gives the default to color output. Same as --color=never.設定ファイルがデフォルトのカラー出力を指定している場合でも、ブランチカラーをオフにします。と同じ--color=neverです。

-i -私
--ignore-case

Sorting and filtering branches are case insensitive.ブランチのソートとフィルタリングは大文字と小文字を区別しません。

--column[=<options>] --column [= <オプション>]
--no-column

Display branch listing in columns. See configuration variable column.branch for option syntax.--column and --no-column without options are equivalent to always and never respectively.支店リストを列で表示します。オプションの構文については構成変数column.branchを参照してください。--columnそして--no-column、オプションなしでは、それぞれalwaysneverと同等です。

This option is only applicable in non-verbose mode.このオプションは、非冗長モードでのみ適用可能です。

-r
--remotes - リモート

List or delete (if used with -d) the remote-tracking branches.リモート追跡ブランチを一覧表示または削除します(-dと共に使用する場合)。

-a
--all - すべて

List both remote-tracking branches and local branches.リモートトラッキングブランチとローカルブランチの両方をリストします。

-l
--list - リスト

List branches. With optional <pattern>..., e.g. git branch --list 'maint-*', list only the branches that match the pattern(s).ブランチをリストします。オプションで<pattern>...、例えばgit branch --list 'maint-*'、パターンにマッチするブランチだけをリストします。

-v
-vv
--verbose - 冗談

When in list mode, show sha1 and commit subject line for each head, along with relationship to upstream branch (if any). If given twice, print the name of the upstream branch, as well (see also git remote show <remote>).リストモードでは、(もしあれば)上流ブランチとの関係とともに、sha1を表示し、各ヘッドの件名をコミットします。2回与えられた場合は、上流のブランチの名前も表示します(こちらも参照git remote show <remote>)。

-q
--quiet - 静か

Be more quiet when creating or deleting a branch, suppressing non-error messages.ブランチを作成または削除するときは、もっと静かにして、エラーのないメッセージを抑制してください。

--abbrev=<length> --abbrev = <長さ>

Alter the sha1’s minimum display length in the output listing. The default value is 7 and can be overridden by the core.abbrev config option.出力リストのsha1の最小表示長を変更します。デフォルト値は7で、core.abbrevconfigオプションで上書きすることができます。

--no-abbrev

Display the full sha1s in the output listing rather than abbreviating them.出力リストに省略形ではなく完全なsha1を表示します。

-t
--track - トラック

When creating a new branch, set up branch.<name>.remote and branch.<name>.merge configuration entries to mark the start-point branch as "upstream" from the new branch. This configuration will tell git to show the relationship between the two branches in git status and git branch -v. Furthermore, it directs git pull without arguments to pull from the upstream when the new branch is checked out.新しいブランチを作成する場合は、セットアップbranch.<name>.remoteおよびbranch.<name>.merge構成エントリは、新しいブランチからの「上流」としてスタートポイントブランチをマークします。この構成は、2つの枝の間の関係を表示するためにgitのを教えてくれますgit statusし、git branch -v。さらに、git pull新しいブランチがチェックアウトされたときに、引数なしでアップストリームからプルするように指示します。

This behavior is the default when the start point is a remote-tracking branch. Set the branch.autoSetupMerge configuration variable to false if you want git checkout and git branch to always behave as if --no-track were given. Set it to always if you want this behavior when the start-point is either a local or remote-tracking branch.この動作は、開始点がリモート追跡ブランチの場合のデフォルトです。branch.autoSetupMergeのコンフィギュレーション変数を設定falseしたい場合git checkoutgit branchかのように常に動作するように--no-track与えられました。always開始点がローカル追跡ブランチまたはリモート追跡ブランチのいずれかである場合にこの動作が必要な場合は、に設定します。

--no-track

Do not set up "upstream" configuration, even if the branch.autoSetupMerge configuration variable is true.branch.autoSetupMerge構成変数がtrueであっても、「アップストリーム」構成をセットアップしないでください。

--set-upstream

As this option had confusing syntax, it is no longer supported. Please use --track or --set-upstream-to instead.このオプションは構文が複雑であるため、サポートされなくなりました。代わりに--trackまたは--set-upstream-toを使用してください。

-u <upstream> -u <上流>
--set-upstream-to=<upstream> --set-upstream-to = <アップストリーム>

Set up <branchname>'s tracking information so <upstream> is considered <branchname>'s upstream branch. If no <branchname> is specified, then it defaults to the current branch.<upstream>が<branchname>のアップストリームブランチと見なされるように、<branchname>の追跡情報を設定します。<branchname>が指定されていない場合は、デフォルトで現在のブランチになります。

--unset-upstream

Remove the upstream information for <branchname>. If no branch is specified it defaults to the current branch.<branchname>のアップストリーム情報を削除します。ブランチが指定されていない場合は、現在のブランチがデフォルトになります。

--edit-description

Open an editor and edit the text to explain what the branch is for, to be used by various other commands (e.g. format-patch, request-pull, and merge (if enabled)). Multi-line explanations may be used.エディタを開き、枝が何のためにあるのかを説明するテキストを編集し、様々な他のコマンドで使用される(例えばformat-patchrequest-pull、およびmerge(有効な場合))。複数行の説明を使用することができます。

--contains [<commit>]

Only list branches which contain the specified commit (HEAD if not specified). Implies --list.指定されたコミットを含むブランチのみを一覧表示します(指定されていない場合はHEAD)。ほのめかし--listます。

--no-contains [<commit>]

Only list branches which don’t contain the specified commit (HEAD if not specified). Implies --list.指定されたコミットを含まないブランチのみを一覧表示します(指定されていない場合はHEAD)。ほのめかし--listます。

--merged [<commit>]

Only list branches whose tips are reachable from the specified commit (HEAD if not specified). Implies --list, incompatible with --no-merged.指定されたコミットから到達可能なヒントを持つブランチのみを一覧表示します(指定されていない場合はHEAD)。含意--list、互換性がありません--no-merged

--no-merged [<commit>]

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

<branchname> <社名>

The name of the branch to create or delete. The new branch name must pass all checks defined by git-check-ref-format[1]. Some of these checks may restrict the characters allowed in a branch name.作成または削除するブランチの名前。新しいブランチ名は、git-check-ref-format [1]で定義されているすべてのチェックに合格する必要があります。これらのチェックの中には、ブランチ名に使用できる文字を制限するものがあります。

<start-point> <開始点>

The new branch head will point to this commit. It may be given as a branch name, a commit-id, or a tag. If this option is omitted, the current HEAD will be used instead.新しいブランチヘッドはこのコミットを指します。ブランチ名、commit-id、またはタグとして指定できます。このオプションを省略すると、現在のHEADが代わりに使用されます。

<oldbranch>

The name of an existing branch to rename.名前を変更する既存のブランチの名前。

<newbranch> <ニューブランチ>

The new name for an existing branch. The same restrictions as for <branchname> apply.既存のブランチの新しい名前。<branchname>と同じ制限が適用されます。

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

Sort based on the key given. Prefix - to sort in descending order of the value. You may use the --sort=<key> option multiple times, in which case the last key becomes the primary key. The keys supported are the same as those in git for-each-ref. Sort order defaults to the value configured for the branch.sort variable if exists, or to sorting based on the full refname (including refs/... prefix). This lists detached HEAD (if present) first, then local branches and finally remote-tracking branches. See git-config[1].与えられたキーに基づいてソートします。-値の降順でソートするためのプレフィックス。--sort = <key>オプションを複数回使用することができます。その場合、最後のキーが主キーになります。サポートされているキーはと同じgit for-each-refです。ソート順は、branch.sort変数が存在する場合はデフォルトで変数に設定された値になるか、完全なrefname(refs/...接頭辞を含む)に基づいてソートされます。これはデタッチされたHEAD(もしあれば)を最初にリストし、次にローカルブランチ、そして最後にリモートトラッキングブランチをリストします。参照のgit-config設定を[1]

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

Only list branches of the given object.与えられたオブジェクトのブランチだけをリストします。

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

A string that interpolates %(fieldname) from a branch ref being shown and the object it points at. The format is the same as that of git-for-each-ref[1].%(fieldname)表示されている分岐参照とそれが指すオブジェクトから補間する文字列。フォーマットはgit-for-each-ref [1]と同じです。

CONFIGURATION設定

pager.branch is only respected when listing branches, i.e., when --list is used or implied. The default is to use a pager. See git-config[1].pager.branchブランチを一覧表示するとき、つまり--listが使用されているか暗黙的に指定されている場合にのみ尊重される デフォルトではポケットベルを使用します。参照のgit-config設定を[1]

EXAMPLES

Start development from a known tag 既知のタグから開発を始める
$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
$ cd my2.6
$ git branch my2.6.14 v2.6.14   (1)
$ git checkout my2.6.14
  1. This step and the next one could be combined into a single step with "checkout -b my2.6.14 v2.6.14".このステップと次のステップは、 "checkout -b my2.6.14 v2.6.14"を使って1つのステップにまとめることができます。

Delete an unneeded branch 不要なブランチを削除する
$ git clone git://git.kernel.org/.../git.git my.git
$ cd my.git
$ git branch -d -r origin/todo origin/html origin/man   (1)
$ git branch -D test                                    (2)
  1. Delete the remote-tracking branches "todo", "html" and "man". The next fetch or pull will create them again unless you configure them not to. See git-fetch[1].リモートトラッキングブランチ "todo"、 "html"、および "man"を削除します。あなたがそれらをにしないように設定しない限り、次のフェッチまたはプルはそれらを再び作成します。git-fetch [1]を参照してください。

  2. Delete the "test" branch even if the "master" branch (or whichever branch is currently checked out) does not have all commits from the test branch."master"ブランチ(または現在チェックアウトされているブランチ)がtestブランチからのコミットをすべて持っていない場合でも、 "test"ブランチを削除します。

NOTESノート

If you are creating a branch that you want to checkout immediately, it is easier to use the git checkout command with its -b option to create a branch and check it out with a single command.すぐにチェックアウトしたいブランチを作成している場合は、git checkoutコマンドを-bオプション付きで使用してブランチを作成し、それを単一のコマンドでチェックアウトする方が簡単です。

The options --contains, --no-contains, --merged and --no-merged serve four related but different purposes:オプションには--contains--no-contains--mergedおよび--no-merged4つの関連するが、異なる目的を果たします:

  • --contains <commit> is used to find all branches which will need special attention if <commit> were to be rebased or amended, since those branches contain the specified <commit>.--contains <commit> <commit>がリベースまたは修正された場合に特別な注意を必要とするすべてのブランチを見つけるために使用されます。それらのブランチには指定された<commit>が含まれているからです。

  • --no-contains <commit> is the inverse of that, i.e. branches that don’t contain the specified <commit>.--no-contains <commit> それはその逆、すなわち指定された<commit>を含まない分岐です。

  • --merged is used to find all branches which can be safely deleted, since those branches are fully contained by HEAD.--merged これらのブランチはHEADに完全に含まれているので、安全に削除できるブランチをすべて見つけるために使用されます。

  • --no-merged is used to find branches which are candidates for merging into HEAD, since those branches are not fully contained by HEAD.--no-merged これらのブランチはHEADに完全には含まれていないため、HEADにマージする候補となるブランチを見つけるために使用されます。

SEE ALSO関連項目

git-check-ref-format[1], git-fetch[1], git-remote[1], “Understanding history: What is a branch?” in the Git User’s Manual.Gitユーザーマニュアルのgit-check-ref-format [1]git-fetch [1]git-remote [1]「履歴の理解:ブランチとは何ですか?」

GIT

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

関連記事

スポンサーリンク

ボックスのセンタリング時に上下マージンが無視される

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

上に戻る