Documentation
¶
Overview ¶
Package reset git-reset - Reset current HEAD to the specified state.
SYNOPSIS ¶
Reference: https://git-scm.com/docs/git-reset
git reset [-q] [<tree-ish>] [--] <paths>... git reset (--patch | -p) [<tree-ish>] [--] [<paths>...] git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
DESCRIPTION ¶
In the first and second form, copy entries from <tree-ish> to the index. In the third form, set the current branch head (HEAD) to <commit>, optionally modifying index and working tree to match. The <tree-ish>/<commit> defaults to HEAD in all forms.
git reset [-q] [<tree-ish>] [--] <paths>...
This form resets the index entries for all <paths> to their state at <tree-ish>. (It does not affect the working tree or the current branch.)
This means that git reset <paths> is the opposite of git add <paths>.
After running git reset <paths> to update the index entry, you can use git-checkout(1) to check the contents out of the index to the working tree. Alternatively, using git-checkout(1) and specifying a commit, you can copy the contents of a path out of a commit to the index and to the working tree in one go.
git reset (--patch | -p) [<tree-ish>] [--] [<paths>...]
Interactively select hunks in the difference between the index and <tree-ish> (defaults to HEAD). The chosen hunks are applied in reverse to the index.
This means that git reset -p is the opposite of git add -p, i.e. you can use it to selectively reset hunks. See the “Interactive Mode” section of git-add(1) to learn how to operate the --patch mode.
git reset [<mode>] [<commit>]
This form resets the current branch head to <commit> and possibly updates the index (resetting it to the tree of <commit>) and the working tree depending on <mode>. If <mode> is omitted, defaults to "--mixed".
Index ¶
- func Commit(hash string) func(*types.Cmd)
- func Hard(g *types.Cmd)
- func HyphenHyphen(g *types.Cmd)
- func Keep(g *types.Cmd)
- func Merge(g *types.Cmd)
- func Mixed(g *types.Cmd)
- func Path(values ...string) func(*types.Cmd)
- func Quiet(g *types.Cmd)
- func Soft(g *types.Cmd)
- func TreeIsh(hash string) func(*types.Cmd)
- func WorkingDir(dir string) func(*types.Cmd)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Hard ¶
Hard Resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded. --hard
func Keep ¶
Keep Resets index entries and updates files in the working tree that are different between <commit> and HEAD. If a file that is different between <commit> and HEAD has local changes, reset is aborted. --keep
func Merge ¶
Merge Resets the index and updates the files in the working tree that are different between <commit> and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added). If a file that is different between <commit> and the index has unstaged changes, reset is aborted.
In other words, --merge does something like a git read-tree -u -m <commit>, but carries forward unmerged index entries.
--merge
func Mixed ¶
Mixed Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action. If -N is specified, removed paths are marked as intent-to-add (see git-add(1)). --mixed
func Soft ¶
Soft Does not touch the index file or the working tree at all (but resets the head to <commit>, just like all modes do). This leaves all your changed files 'Changes to be committed', as git status would put it. --soft
func WorkingDir ¶
WorkingDir Sets the working dir use for the git command. --working-dir=<dir>
Types ¶
This section is empty.