As per this question (Git: I want to refactor my codebase, and create new files structures and move things around. Will my git history be maintained?) I refactored my project, and moved all of my files using the "git mv" command. After committing my refactoring work, I look at my bitbucket repo, and when I look at the history of any of the files that were moved... they only have the most recent refactoring commit. All the history for every file that was moved is no longer present. Why is this?
Asked
Active
Viewed 1,054 times
3
-
Your tool needs to be able to handle renames to show history correctly. If you want to make it look like the file has always been in the new location you need to rewrite all the commits with the file in it. It is possible to do, but you have to be a bit careful. – Thorbjørn Ravn Andersen Jul 08 '15 at 22:10
-
Did you use `git push -f` at any stage? What does the `git log` say at command line? (git is expected to preserve the entire history even after `git mv`. I just did the whole thing and it shows full history) – FractalSpace Jul 08 '15 at 23:20
-
@FractalSpace When I `git log`, all of my recent commits exist. But when I go to the file, it history is not there. How can I view the history for a git moved file? – chris P Jul 08 '15 at 23:40
-
@ThorbjørnRavnAndersen Is it too late for me? I don't need to make it look like it always been in the new location, I would just like to find the previous history for all these files. – chris P Jul 08 '15 at 23:41
1 Answers
2
Commits for a file that has been moved can be found by
git log --follow <some path to a moved file>
See more at Is it possible to move/rename files in git and maintain their history?
-
Yup, there they all are! I often like to look at my history through bitbucket as opposed to command line. Do you know if it's possible via the bitbucket interface? – chris P Jul 09 '15 at 01:33
-
Sorry, no. As you know, they have an open request from 2009 on this issue (https://bitbucket.org/site/master/issues/589/file-history-should-follow-copies-and) – joran Jul 09 '15 at 07:01
-
are you aware of github has this functionality that bit bucket does not. If so, I might have to make the switch. – chris P Jul 09 '15 at 14:28