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

"git rm" could be safer and have a better help msg

From
Tom Browder <tom.browder@gmail.com>
Date
Jul 10, 2020, 12:25 UTC
Message-ID
<CAFMGiz97fcw_nvaa=Xo-roTtB1o25qO06=PHGSrBzv4k_zGqaw@mail.gmail.com>

I often need to remove a file from Git but leave it as is, changed or not. The only safe way to do that as far as I know is:

    $ git rm -f --cached myfile   # many thanks to @jast on IRC #git

The "git help rm" command yields copious information but nowhere can I find a clear statement about safely removing a modified file from Git without removing it from the file system.

I am going to create an alias to help me, but I believe the brute force removal should be a different option, say, '-F' ('--Force'), and the existing '-f' ('--force') ought to be safe operations as far as the file system is concerned.

Best regards,
-Tom
Next: Andreas Schwab
Message 1 of 6 in “"git rm" could be safer and have a better help msg”
  1. Tom BrowderJul 10, 2020
  2. Andreas SchwabJul 10, 2020
  3. Tom BrowderJul 10, 2020
  4. Andreas SchwabJul 10, 2020
  5. Tom BrowderJul 10, 2020
  6. Aaron SchrabJul 10, 2020

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.