git移动文件,同时保持历史 [英] git moving file while keeping history
问题描述
我们要将一个名为Workflows的目录从
源/工作流
移动到新位置
Source / Sites / CompanySite / Workflows
我的同事将该目录的副本复制到新位置Source / Sites / CompanySite / Workflows,并在执行git mv之前签入命令,甚至做一个动作。
因此,我们在该位置有新文件,没有历史记录。
但是因为我们只想移动文件来保存历史记录,所以我删除了新的副本,并试图在保留历史记录的同时,执行git mv移动源文件。
我知道git会认识到我们正在重命名,即使没有git mv
但是因为我的同事副本已经有了一个历史记录(这是一个空的一个),所以即使我删除它,它保持了新的历史。
然后无论我做什么,我都无法将这些文件移动到它们的原始历史记录。
<因为它始终保留着那里的新历史。
我希望我的问题很明确
如何移动这些文件以保留其历史记录。
可能会清除那个旧副本???????????????????????????????????????????????????????????????????????????? code>实际上并不能确保Git将它视为一种行为;无论如何,它仍然可以将其视为删除+添加。
如果您需要历史记录,请尝试传递 - 遵循
>标记为 git log
- 它可以识别与原始文件的连接并显示它的历史记录。
we are using git at work. we want to move a directory called "Workflows" from under Source/Workflows
to a new location Source/Sites/CompanySite/Workflows
my colleague did a copy of that directory to the new location "Source/Sites/CompanySite/Workflows" and checked-in before doing a "git mv" command or even doing a move.
So, we have new copies of the files in that location with no history.
But because we want to just move files keeping their history, so I deleted the new copy and tried to do "git mv" to move the source files, while keeping the history. And I know that git will recognize that we are renaming even without "git mv"
But because my colleague copy has already a history there (which is an empty one), so even when I delete it it keep that "new history".
Then no matter what I do, I am not able to move those files with their "original history".
because it always keeping the "new history" that was there.
I hope my question is clear
How can I move these files keeping their history. maybe "purging" that old copy????
git mv
doesn't actually ensure that Git will see it as a move; it may still treat it as a delete + addition, anyway. Git infers moves, but doesn't record them.
If you want the history, try passing the --follow
flag to git log
—it may be able to recognize the connection to the original and show the history for it.
这篇关于git移动文件,同时保持历史的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!