简体   繁体   English

Git将本地历史记录合并到远程存储库

[英]Git merge local history to remote repository

I have restructured my project folders. 我已经重组了项目文件夹。 I see that i lost commit history before restructuring of files in my remote repository. 我看到在重组远程存储库中的文件之前丢失了提交历史记录。

I have the history before restructuring locally. 在进行本地重组之前,我拥有历史。 Right now everyone who clone the repository doesn't have the commit history before restructuring. 现在,克隆存储库的每个人在重组之前都没有提交历史记录。 Is there anyway i can rebuild the commit history and merge it to the remote repository? 无论如何,我可以重建提交历史记录并将其合并到远程存储库吗?

When i try this command : 当我尝试此命令时:

git log --follow pom.xml

I can see full history of file, but when i dont use --follow the log stops at restructuring commit.I would like that it shows all the history. 我可以看到文件的完整历史记录,但是当我不使用--follow时,日志将在重组commit时停止。我希望它显示所有历史记录。 Is there any way to fix this? 有没有什么办法解决这一问题?

The only way to lose history in Git is to remove commits. 在Git中丢失历史记录的唯一方法是删除提交。 This is because the commits are the history. 这是因为提交历史记录。 There is no file history; 没有文件历史记录; there are only commits. 只有提交。

When you use git log --follow pom.xml , you are telling Git to synthesize a file history, by wandering through the commit history and noting when a file named pom.xml is touched. 当您使用git log --follow pom.xml ,您通过在提交历史中徘徊并指出何时触摸了名为pom.xml的文件来告诉Git 合成文件历史。 The --follow option tells Git that in addition to checking to see if pom.xml is changed in that commit, it should also check to see if it is renamed in that commit. --follow选项告诉Git,除了检查该提交中是否更改pom.xml ,还应该检查该提交中是否将其重命名 If so, Git checks earlier commits for the old name (including its full directory path) instead of the new name—so Git is no longer looking for new/pom.xml but now looking for old/pom.xml or whatever, and constructing a file history for that file. 如果是这样,Git会检查早期提交中的旧名称 (包括其完整目录路径)而不是新名称,因此Git不再寻找new/pom.xml而是寻找old/pom.xml或其他任何东西,并构造文件历史记录文件。

If you use an IDE, the IDE must do the same thing as Git—synthesize a file history by selecting commits that change that file, and check for rename operations in the process, if that's what you want it to do. 如果使用IDE,则IDE必须执行与Git相同的操作-通过选择更改该文件的提交来合成文件历史记录,并在此过程中检查重命名操作(如果您要执行此操作)。

Finally i found out thats an issue only on Bitbucket and Eclipse. 最终,我发现仅在Bitbucket和Eclipse上存在一个问题。 Bitbucket shows all commits to the repository but can not show the sinbgle file log with the command --follow. Bitbucket显示对存储库的所有提交,但无法使用--follow命令显示单文件日志。 The same issue is with Eclipse. Eclipse也存在同样的问题。 Intellij works fine. Intellij正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM