reset

package
v2.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Commit

func Commit(hash string) func(*types.Cmd)

Commit [<commit>]

func Hard

func Hard(g *types.Cmd)

Hard Resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded. --hard

func HyphenHyphen

func HyphenHyphen(g *types.Cmd)

HyphenHyphen add `--`

func Keep

func Keep(g *types.Cmd)

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

func Merge(g *types.Cmd)

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

func Mixed(g *types.Cmd)

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 Path

func Path(values ...string) func(*types.Cmd)

Path <paths>...

func Quiet

func Quiet(g *types.Cmd)

Quiet Be quiet, only report errors. -q, --quiet

func Soft

func Soft(g *types.Cmd)

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 TreeIsh

func TreeIsh(hash string) func(*types.Cmd)

TreeIsh [<tree-ish>]

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL