gpt4 book ai didi

git - 是否可以在 Git 中移动/重命名文件并维护它们的历史记录?

转载 作者:IT王子 更新时间:2023-10-29 01:09:11 26 4
gpt4 key购买 nike

我想在 Git 中重命名/移动一个项目子树,从中移动它

/project/xyz

/components/xyz

如果我使用普通的 git mv project components,那么 xyz project 的所有提交历史都会丢失。有没有办法移动它以维护历史记录?

最佳答案

Git 检测重命名而不是将操作与提交持久化,因此无论您使用 git mv 还是 mv 都没有关系。

log 命令需要一个 --follow在重命名操作之前继续历史的参数,即,它使用启发式搜索相似的内容。

要查找完整的历史记录,请使用以下命令:

git log --follow ./path/to/file

关于git - 是否可以在 Git 中移动/重命名文件并维护它们的历史记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2314652/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com