Português (Brasil) ▾ Topics ▾ Latest version ▾ git-reset last updated in 2.54.0

NOME

git-reset - Redefine o HEAD atual para a condição usada

RESUMO

git reset [-q] [<tree-ish>] [--] <pathspec>…​
git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]
git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>…​]
git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]

DESCRIÇÃO

In the first three forms, copy entries from <tree-ish> to the index. In the last 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>] [--] <pathspec>...
git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]

These forms reset the index entries for all paths that match the <pathspec> to their state at <tree-ish>. (It does not affect the working tree or the current branch.)

Isto significa que git reset <pathspec> é o oposto de git add <pathspec>. Este comando é equivalente a git restore [--source=<árvore>] --staged <pathspec>....

Depois de executar o git reset <pathspec> para atualizar a entrada do índice, você pode usar o git-restore[1] para verificar o conteúdo do índice para a árvore de trabalho. Como alternativa, utilizando git-restore[1] e especificando um commit com --source, você pode copiar o conteúdo de um caminho de um commit para o índice e a árvore de trabalho de uma vez só.

git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]

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>. Before the operation, ORIG_HEAD is set to the tip of the current branch. If <mode> is omitted, defaults to --mixed. The <mode> must be one of the following:

--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.

--mixed

Redefine o índice, mas não a árvore de trabalho (ou seja, os arquivos alterados são preservados, mas não marcados para um commit) e relata o que não foi atualizado. Esta é a ação predefinida.

Caso -N seja especificado, os caminhos removidos serão marcados como uma intenção de adicionar (consulte git-add[1]).

--hard

Resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded. Any untracked files or directories in the way of writing any tracked files are simply deleted.

--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.

Em outras palavras, --merge faz algo como um git read-tree -u -m <commit>, mas carrega as entradas do índice não mescladas adiante.

--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.

--recurse-submodules
--no-recurse-submodules

When the working tree is updated, using --recurse-submodules will also recursively reset the working tree of all active submodules according to the commit recorded in the superproject, also setting the submodules' HEAD to be detached at that commit.

Para as diferenças entre os três comandos consulte "Redefinir, restaurar e reverter" em git[1].

OPÇÕES

-q
--quiet

Fique em silêncio, reporte apenas as mensagens de erro.

--refresh
--no-refresh

Atualize o índice após uma redefinição mista. Ativado por padrão.

--pathspec-from-file=<file>

Pathspec is passed in <file> instead of commandline args. If <file> is exactly - then standard input is used. Pathspec elements are separated by LF or CR/LF. Pathspec elements can be quoted as explained for the configuration variable core.quotePath (see git-config[1]). See also --pathspec-file-nul and global --literal-pathspecs.

--pathspec-file-nul

Only meaningful with --pathspec-from-file. Pathspec elements are separated with NUL character and all other characters are taken literally (including newlines and quotes).

Warning

Missing pt_BR/diff-context-options.adoc

See original version for this content.

--

Não interprete mais argumentos como opções.

<pathspec>...

Limita os caminhos afetados pela operação.

Para mais detalhes sobre a sintaxe, consulte a entrada pathspec em