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

Re: Deleting files

From
PBPieter de Bie <pdebie@ai.rug.nl>
Date
Jun 12, 2008, 12:11 UTC
Message-ID
<477B22F6-9F24-4CBE-98EE-58EF697E6320@ai.rug.nl>
In-Reply-To
<g2r36d$2ju$1@ger.gmane.org>
On 12 jun 2008, at 14:01, Shak wrote:
> This is all becoming very counter-intuitive :(
It seems you are missing the concept of the index. Let's look
at an example:
Vienna:a pieter$ git init
Initialized empty Git repository in /Users/pieter/a/.git/
Vienna:a pieter$ touch a b
Vienna:a pieter$ git commit -m "Initial commit"
Created initial commit f0a0fe2: Initial commit
  0 files changed, 0 insertions(+), 0 deletions(-)
  create mode 100644 a
  create mode 100644 b
Vienna:a pieter$ rm a
Vienna:a pieter$ git status
# On branch master
# Changed but not updated:
#   (use "git add/rm <file>..." to update what will be committed)
#
#       deleted:    a
#

This is the point where you were. Look at the line "Changed but no updated" and also the hint "(use "git add/rm <file>..." to update what will be committed)".

Vienna:a pieter$ echo "text" >b && git add b && git commit -m "change"
Created commit e28a131: change
  1 files changed, 1 insertions(+), 0 deletions(-)

You changed b and commited it, but did nothing with a. now when you do git status:

Vienna:a pieter$ git status # On branch master # Changed but not updated: # (use "git add/rm <file>..." to update what will be committed) # # deleted: a # no changes added to commit (use "git add" and/or "git commit -a")

It'll still show it as deleted. And still gives you a hint on what to do (TWICE!). So, let's do that:

Vienna:a pieter$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: a #

Notice that it now says "Changes to be committed"! If you commit now, your status will be clean:

Vienna:a pieter$ git commit -m "deleted a"
Created commit 02bbe7b: deleted a
  0 files changed, 0 insertions(+), 0 deletions(-)
  delete mode 100644 a
Vienna:a pieter$ git status
# On branch master
nothing to commit (working directory clean)

In short, the point is that you never commited the deletions! Your whole history until now will still show those deleted files. You can commit the actually deletions now, as you should have done before (either by using "git rm <file>", "git add -u", "git commit -a" or "git commit <file>".

- Pieter
Previous: ShakNext: Shak
Message 4 of 6 in “Deleting files”
  1. ShakJun 12, 2008
  2. ShakJun 12, 2008
  3. ShakJun 12, 2008
  4. Pieter de BieJun 12, 2008
  5. ShakJun 12, 2008
  6. Alex RiesenJun 12, 2008

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.