Git development
 help / color / mirror / Atom feed
* Git add on deleted file
@ 2012-08-13 17:34 Angus Hammond
  2012-08-13 17:54 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Angus Hammond @ 2012-08-13 17:34 UTC (permalink / raw)
  To: git

I was messing around with git add and how it interacts with deleted
files earlier today and came across this odd behavior.

$git init
Initialized empty Git repository in /tmp/test/.git/
$touch foo
$git add foo
$git commit -m"initial commit"
[master (root-commit) 0b5a193] initial commit
 0 files changed
 create mode 100644 foo
$rm foo
$git status
# On branch master
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       deleted:    foo
#
no changes added to commit (use "git add" and/or "git commit -a")
$git add foo
$git status
# On branch master
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       deleted:    foo
#
no changes added to commit (use "git add" and/or "git commit -a")

Notice that the two outputs from git status are identical, so git add
doesn't appear to have changed anything. Personally I'd like to see
"git add foo" here be equivalent "git rm --cached foo", but I can
understand how others might prefer git add not to be destructive like
that. Either way, I don't think it's right that the command exits
without any output (which would normally indicate success) yet has
failed to do anything. Perhaps it should act more like git add does
when the file doesn't exist in the working directory or the index:

$git add bar
fatal: pathspec 'bar' did not match any files

Thanks
Angus

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-13 18:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-13 17:34 Git add on deleted file Angus Hammond
2012-08-13 17:54 ` Junio C Hamano
2012-08-13 18:18   ` Ralf Thielow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox