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

How to undo changes?

From
LMLin Mac <mkl0301@gmail.com>
Date
Apr 29, 2010, 01:08 UTC
Message-ID
<l2l10d816431004281808s79a559e6p308052c788c9a4ca@mail.gmail.com>
Hi,

1. I have multiple files modified, but would like to undo the changes in one of the changed files. "git reset --hard" do not accept single files. So I used to use "git diff <file> | patch -p X", but X cannot be know until I checked the patch and know the path relationship. Is there other way to do it?

2. Sometimes I delete old unused branches with "git branch -D <branch>", but I just realized theren't a reflog log for such operation. If the branch is the only reference to the logs, deleting the branch makes the commits become dangling commits. How could I recover those commit?

I run into situation 1 from time to time. Luckily I have never ran into situation 2, but would like to know the recovery ways. Thanks in advance.

Best Regards, Mac Lin

Next: Erik Faye-Lund
Message 1 of 2 in “How to undo changes?”
  1. Lin MacApr 29, 2010
  2. Erik Faye-LundApr 29, 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.