本文介绍了git-mv显示文件已删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行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-mved 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显示文件已删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 08:26