更改 git 项目中的子文件夹名称而不丢失文件历史记录?
仅供参考,我对 git 还很陌生,主要使用 gitgui。
当我更改项目中包含已跟踪文件的已跟踪文件夹的名称时,git 会将该文件夹中的所有文件视为新的未跟踪文件。如何让 git 了解我只是更改了文件夹的名称,这样我就不会“丢失”该文件夹中包含的文件的历史记录?
FYI, I'm pretty new to git, using mostly gitgui.
When I change the name of an already tracked folder containing already tracked files in my project, git sees all the files in the folder as new untracked files. How do I make git understand that I only changed the name of the folder, so that I don't "lose" the history of the files contained in that folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Git 不会明确跟踪移动/重命名或副本。相反,它会在需要时检测它们。执行此操作,然后运行 git diff -M 。
Git doesn't explicitly track moves/renames or copies. Instead, it detects them when it's asked to. Do the move, and run
git diff -M
.下面的一些例子表明 Git 确实是一个内容跟踪器:
因此,您不必明确告诉 Git 有关副本或移动的信息:它会自动检测它们。
Here are some examples to show that Git is really a content tracker:
Therefore, you don't have to tell Git explicitly about copies or moves: it will detect them automatically.
Git 不关心你的文件或文件夹。我在那里说了。它会跟踪您的内容。移动文件后,它会在 git status 中显示为删除一组文件/文件夹并创建文件/文件夹。提交后,Git 将检测到它已经看到了这一确切内容,并且不仅能够跟踪“文件”和“文件夹”,而且即使您通过管理块的方式将代码从一个文件移动到另一个文件也是如此。
欢迎来到 Git!
Git doesn't care about your files or folders. There I said it. It tracks your content. After you move your files it'll show in git status as deleting a set of files/folders and a creation of files/folders. After your commit Git will detect that it's already seen this exact content and be able to follow not only the "files" and "folders" but even if you moved code from one file to another by the way it manages chunks.
Welcome to Git!