Rechercher une page de manuel
git-reset
Langue: en
Version: 02/20/2009 (ubuntu - 07/07/09)
Section: 1 (Commandes utilisateur)
NAME
git-reset - Reset current HEAD to the specified stateSYNOPSIS
-
git reset [--mixed | --soft | --hard] [-q] [<commit>] git reset [-q] [<commit>] [--] <paths>...
DESCRIPTION
Sets the current head to the specified commit and optionally resets the index and working tree to match.This command is useful if you notice some small error in a recent commit (or set of commits) and want to redo that part without showing the undo in the history.
If you want to undo a commit other than the latest on a branch, git-revert(1) is your friend.
The second form with paths is used to revert selected paths in the index from a given commit, without moving HEAD.
OPTIONS
--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.
--soft
- Does not touch the index file nor the working tree at all, but requires them to be in a good order. This leaves all your changed files "Changes to be committed", as git-status would put it.
--hard
- Matches the working tree and index to that of the tree being switched to. Any changes to tracked files in the working tree since <commit> are lost.
-q
- Be quiet, only report errors.
<commit>
- Commit to make the current HEAD. If not given defaults to HEAD.
EXAMPLES
Undo a commit and redo
-
-
$ git commit ... $ git reset --soft HEAD^ ▓fB(1)▓fR $ edit ▓fB(2)▓fR $ git commit -a -c ORIG_HEAD ▓fB(3)▓fR
See also the --amend option to git-commit(1). ⌂br
-
Undo commits permanently
-
-
$ git commit ... $ git reset --hard HEAD~3 ▓fB(1)▓fR
-
Undo a commit, making it a topic branch
-
-
$ git branch topic/wip ▓fB(1)▓fR $ git reset --hard HEAD~3 ▓fB(2)▓fR $ git checkout topic/wip ▓fB(3)▓fR
-
Undo add
-
-
$ edit ▓fB(1)▓fR $ git add frotz.c filfre.c $ mailx ▓fB(2)▓fR $ git reset ▓fB(3)▓fR $ git pull git://info.example.com/ nitfol ▓fB(4)▓fR
-
Undo a merge or pull
-
-
$ git pull ▓fB(1)▓fR Auto-merging nitfol CONFLICT (content): Merge conflict in nitfol Automatic merge failed/prevented; fix up by hand $ git reset --hard ▓fB(2)▓fR $ git pull . topic/branch ▓fB(3)▓fR Updating from 41223... to 13134... Fast forward $ git reset --hard ORIG_HEAD ▓fB(4)▓fR
-
Interrupted workflow
- Suppose you are interrupted by an urgent fix request while you are in the middle of a large change. The files in your working tree are not in any shape to be committed yet, but you need to get to the other branch for a quick bugfix.
-
-
$ git checkout feature ;# you were working in "feature" branch and $ work work work ;# got interrupted $ git commit -a -m "snapshot WIP" ▓fB(1)▓fR $ git checkout master $ fix fix fix $ git commit ;# commit with real log $ git checkout feature $ git reset --soft HEAD^ ;# go back to WIP state ▓fB(2)▓fR $ git reset ▓fB(3)▓fR
-
Reset a single file in the index
- Suppose you have added a file to your index, but later decide you do not want to add it to your commit. You can remove the file from the index while keeping your changes with git reset.
-
-
$ git reset -- frotz.c ▓fB(1)▓fR $ git commit -m "Commit files in index" ▓fB(2)▓fR $ git add frotz.c ▓fB(3)▓fR
-
AUTHOR
Written by Junio C Hamano <gitster@pobox.com[1]> and Linus Torvalds <torvalds@osdl.org[2]>DOCUMENTATION
Documentation by Junio C Hamano and the git-list <git@vger.kernel.org[3]>.GIT
Part of the git(1) suiteNOTES
- 1.
- gitster@pobox.com
- mailto:gitster@pobox.com
- 2.
- torvalds@osdl.org
- mailto:torvalds@osdl.org
- 3.
- git@vger.kernel.org
- mailto:git@vger.kernel.org
Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre