git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git reset -p on working tree

From
knittl <knittl89@googlemail.com>
Date
Nov 23, 2010, 10:58 UTC
Message-ID
<AANLkTi=5w3YpYu0_WbmHud0BUkO2BqYNVezWDMkCaSj2@mail.gmail.com>
In-Reply-To
<AANLkTindHnjeXEGbKWiQkWgoUBwqZbdx71sQwNr_gFp0@mail.gmail.com>
On Tue, Nov 23, 2010 at 11:32 AM, Jeenu V <jeenuv@gmail.com> wrote:
Show 18 quoted lines
> On Tue, Nov 23, 2010 at 3:56 PM, Jeenu V <jeenuv@gmail.com> wrote:
>> On Tue, Nov 23, 2010 at 2:50 PM, knittl <knittl89@googlemail.com> wrote:
>>>> Right now I do this with vimdiff, by applying 'git diff' in reverse.
>>>> Wish reset supports -p on working tree operations as well because the
>>>> -p framework (of add, and reset) feels good to use.
>>>
>>>
>>> there's `git checkout -p` to selectively remove changes from your working tree.
>>> (also `git stash -p` to selectively stash changes temporarily)
>>
>> Surprised to know that checkout and stash supports it! Thanks a lot
>> for pointing out.
>
> I think Git could suggest 'checkout -p' and/or 'stash -p' when user
> tries to use -p with --{hard,soft,mixed} with reset command (in
> addition to mentioning that they're incompatible), since relatively
> new users are used to 'reset' than other commands to reset their
> working trees.

`git reset` seldomly affects the working tree, unless using `--hard`, `--merge` or `--keep`, and those switches are potentially dangerous if you are not aware of the implications to your worktree and index.

without options reset undoes a previous add, i.e. remove changes from the index, but not the working tree.

git reset manpage mentions git-checkout:
Show 5 quoted lines
> 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.

-- typed with http://neo-layout.org myFtPhp -- visit http://myftphp.sf.net -- v. 0.4.7 released!

Previous: Jeenu VNext: Jeenu V
Message 5 of 14 in “Git reset -p on working tree”
  1. Jeenu VNov 23, 2010
  2. knittlNov 23, 2010
  3. Jeenu VNov 23, 2010
  4. Jeenu VNov 23, 2010
  5. knittlNov 23, 2010
  6. Jeenu VNov 23, 2010
  7. Hint at "checkout -p" in the "reset --patch <type>" error messageŠtěpán Němec, Nov 23, 2010
  8. Jeff KingNov 23, 2010
  9. Štěpán NěmecNov 23, 2010
  10. Michael J GruberNov 25, 2010
  11. Jakub NarebskiNov 25, 2010
  12. Michael J GruberNov 25, 2010
  13. Matthieu MoyNov 25, 2010
  14. Jeff KingNov 25, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.