简体   繁体   中英

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. Is there any way to fix this?

The only way to lose history in Git is to remove commits. 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. 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. 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.

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.

Finally i found out thats an issue only on Bitbucket and Eclipse. Bitbucket shows all commits to the repository but can not show the sinbgle file log with the command --follow. The same issue is with Eclipse. Intellij works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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