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

Reverting a subdirectory of a repo

From
Jay Soffian <jaysoffian@gmail.com>
Date
May 15, 2011, 13:10 UTC
Message-ID
<BANLkTikzV7EHyZUqUXqORebjWAkb_PAX6w@mail.gmail.com>

Recently I wanted to revert a subdirectory of a repo to an earlier state, so I did this:

$ git checkout <revision> -- /path/to/subdir $ git commit

And I was surprised that the subdir retained files that had been added since <revision>. To get a clean revert, I had to:

$ git rm -r /path/to/subdir $ git checkout <revision> -- /path/to/subdir $ git commmit

And I'm wondering if requiring the "rm" first is bug or a feature. On the one hand, in retrospect I understand why it's needed, but otoh, it did catch me off guard the first time.

j.
Message 1 of 1 in “Reverting a subdirectory of a repo”
  1. Jay SoffianMay 15, 2011

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.