Git add on deleted file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]