Documentation
¶
Overview ¶
Package checkout git-checkout - Switch branches or restore working tree files.
SYNOPSIS ¶
Reference: https://git-scm.com/docs/git-checkout
git checkout [-q] [-f] [-m] [<branch>] git checkout [-q] [-f] [-m] --detach [<branch>] git checkout [-q] [-f] [-m] [--detach] <commit> git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>] git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>... git checkout [-p|--patch] [<tree-ish>] [--] [<paths>...]
DESCRIPTION ¶
Updates files in the working tree to match the version in the index or the specified tree. If no paths are given, git checkout will also update HEAD to set the specified branch as the current branch.
Index ¶
- func Branch(name string) func(*types.Cmd)
- func Conflict(style string) func(*types.Cmd)
- func Detach(g *types.Cmd)
- func Force(g *types.Cmd)
- func IgnoreOtherWorktrees(g *types.Cmd)
- func IgnoreSkipWorktreeBits(g *types.Cmd)
- func Merge(g *types.Cmd)
- func NewBranch(value string) func(*types.Cmd)
- func NewBranchForce(newBranch string) func(*types.Cmd)
- func NewBranchReflog(g *types.Cmd)
- func NoProgress(g *types.Cmd)
- func NoRecurseSubmodules(g *types.Cmd)
- func NoTrack(g *types.Cmd)
- func Orphan(newBranch string) func(*types.Cmd)
- func Ours(g *types.Cmd)
- func Patch(g *types.Cmd)
- func Path(values ...string) func(*types.Cmd)
- func Progress(g *types.Cmd)
- func Quiet(g *types.Cmd)
- func RecurseSubmodules(g *types.Cmd)
- func StartPoint(name string) func(*types.Cmd)
- func Theirs(g *types.Cmd)
- func Track(g *types.Cmd)
- func TreeIsh(value string) func(*types.Cmd)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Branch ¶
Branch to checkout; if it refers to a branch (i.e., a name that, when prepended with 'refs/heads/', is a valid ref), then that branch is checked out. Otherwise, if it refers to a valid commit, your HEAD becomes 'detached' and you are no longer on any branch (see below for details). <branch> or <new_branch> Name for the new branch.
func Conflict ¶ added in v0.6.0
Conflict The same as --merge option above, but changes the way the conflicting hunks are presented, overriding the merge.conflictStyle configuration variable. Possible values are 'merge' (default) and 'diff3' (in addition to what is shown by 'merge' style, shows the original contents). --conflict=<style>
func Detach ¶
Detach Rather than checking out a branch to work on it, check out a commit for inspection and discardable experiments. This is the default behavior of 'git checkout <commit>' when <commit> is not a branch name. See the 'DETACHED HEAD' section below for details. --detach
func Force ¶
Force When switching branches, proceed even if the index or the working tree differs from HEAD. This is used to throw away local changes. When checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored. -f, --force
func IgnoreOtherWorktrees ¶
IgnoreOtherWorktrees git checkout refuses when the wanted ref is already checked out by another worktree. This option makes it check the ref out anyway. In other words, the ref can be held by more than one worktree. --ignore-other-worktrees
func IgnoreSkipWorktreeBits ¶
IgnoreSkipWorktreeBits In sparse checkout mode, git checkout -- <paths> would update only entries matched by <paths> and sparse patterns in $GIT_DIR/info/sparse-checkout. This option ignores the sparse patterns and adds back any files in <paths>. --ignore-skip-worktree-bits
func Merge ¶
Merge When switching branches, if you have local modifications to one or more files that are different between the current branch and the branch to which you are switching, the command refuses to switch branches in order to preserve your modifications in context. However, with this option, a three-way merge between the current branch, your working tree contents, and the new branch is done, and you will be on the new branch. -m, --merge
func NewBranch ¶
NewBranch Create a new branch named <new_branch> and start it at <start_point>; see git-branch(1) for details. -b [new_branch]
func NewBranchForce ¶
NewBranchForce Creates the branch <new_branch> and start it at <start_point>; if it already exists, then reset it to <start_point>. This is equivalent to running 'git branch' with '-f'; see git-branch(1) for details. -B [new_branch]
func NewBranchReflog ¶ added in v0.13.0
NewBranchReflog Create the new branch’s reflog; see git-branch(1) for details. -l
func NoProgress ¶
NoProgress Progress status is reported on the standard error stream by default when it is attached to a terminal, unless --quiet is specified. This flag enables progress reporting even if not attached to a terminal, regardless of --quiet. --no-progress
func NoRecurseSubmodules ¶
NoRecurseSubmodules Using --recurse-submodules will update the content of all initialized submodules according to the commit recorded in the superproject. If local modifications in a submodule would be overwritten the checkout will fail unless -f is used. If nothing (or --no-recurse-submodules) is used, the work trees of submodules will not be updated. --no-recurse-submodules
func NoTrack ¶
NoTrack Do not set up 'upstream' configuration, even if the branch.autoSetupMerge configuration variable is true. --no-track
func Orphan ¶
Orphan Create a new orphan branch, named <new_branch>, started from <start_point> and switch to it. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits. --orphan <new_branch>
func Ours ¶
Ours When checking out paths from the index, check out stage #2 (ours) or #3 (theirs) for unmerged paths. --ours, --theirs
func Patch ¶
Patch Interactively select hunks in the difference between the <tree-ish> (or the index, if unspecified) and the working tree. The chosen hunks are then applied in reverse to the working tree (and if a <tree-ish> was specified, the index). -p, --patch
func Progress ¶
Progress Progress status is reported on the standard error stream by default when it is attached to a terminal, unless --quiet is specified. This flag enables progress reporting even if not attached to a terminal, regardless of --quiet. --progress
func RecurseSubmodules ¶
RecurseSubmodules Using --recurse-submodules will update the content of all initialized submodules according to the commit recorded in the superproject. If local modifications in a submodule would be overwritten the checkout will fail unless -f is used. If nothing (or --no-recurse-submodules) is used, the work trees of submodules will not be updated. --recurse-submodules
func StartPoint ¶ added in v0.5.0
StartPoint The name of a commit at which to start the new branch; see git-branch(1) for details. Defaults to HEAD. <start_point>
func Theirs ¶
Theirs When checking out paths from the index, check out stage #2 (ours) or #3 (theirs) for unmerged paths. --ours, --theirs
Types ¶
This section is empty.