问题描述
当我运行git-mv file1 file2
时,正如我期望的那样,我将文件从file1
移到了file2
.但是,有时我的git status
给我的输出是奇数".
When I run git-mv file1 file2
, I get the file moved from file1
to file2
as I'd expect. Sometimes, though, my git status
gives me 'odd' output.
当我运行git-mv f1 f2
时,然后是git status
:
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: f1 -> f2
这就是我所期望的.但是,有时候我提交f2
后,我得到:
That's what I'd expect. Other times, though, after I've committed f2
, I get:
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: f1
通常在我提交新文件后发生.我不知道为什么为什么发生-它似乎是随机发生的(因为通常我会收到renamed: f1->f2
消息,就像我期望的那样).
This generally happens after I've committed the new file. I don't know why it happens - it seems to occur at random (because generally I get the renamed: f1->f2
message, like I'm expecting).
我想知道为什么有时我会收到消息,说我在运行git mv
后删除了该文件,以及生成该文件需要经历哪些步骤-我刚刚尝试进行复制,并且得到了renamed:..
;但是10分钟之前,我在那个之前大约10分钟git-mv
的文件上看到了deleted:...
的字样.这让我很困惑.
I'd like to know why I sometimes get messages saying I've deleted the file after I run git mv
, and what steps I'd have gone through to produce this - I've just tried to reproduce, and got renamed:..
; but 10 minutes ago I got a deleted:...
on a file I'd git-mv
ed about 10 minutes before that. It's confusing me greatly.
推荐答案
听起来像您将f1
重命名为f2
,但是仅提交了f2
的添加,而不删除了f1
.如果您使用git mv f1 f2
但随后键入git commit f2
,则可能会发生这种情况;或者,如果键入mv f1 f2
然后执行git add .; git commit
It sounds like you renamed f1
to f2
, but only committed the addition of f2
and not the removal of f1
. This can happen if you use git mv f1 f2
but then type git commit f2
, or it can happen if you type mv f1 f2
and then do something like git add .; git commit
这篇关于git-mv显示文件已删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!