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

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

From
Andreas Schwab <schwab@linux-m68k.org>
Date
Jul 10, 2020, 14:04 UTC
Message-ID
<874kqf1n65.fsf@igel.home>
In-Reply-To
<CAFMGiz8+pjskPpPqVgQUevKdWgxPvCKBcmx-07E2yizDqhm9mg@mail.gmail.com>
On Jul 10 2020, Tom Browder wrote:
> If the existing file has been modified, with 'rm'  the '--cached'
> option doesn't remove it from Git
> unless one uses the '-f' option with it.
It doesn't?  Worksforme.

$ echo >> zlib.c $ git status On branch master Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   zlib.c

no changes added to commit (use "git add" and/or "git commit -a") $ git rm --cached zlib.c rm 'zlib.c' $ git status On branch master Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    zlib.c
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        zlib.c
Andreas.
-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Previous: Tom BrowderNext: Tom Browder
Message 4 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.